> This page is for version v2 (default).
> For other versions, use one of these documentation indexes:
> - v2 (default): https://docs.paid.ai/v-2/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.paid.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.paid.ai/_mcp/server.

# Create customer alias

POST https://api.agentpaid.io/api/v2/customers/{id}/aliases
Content-Type: application/json

Create an alternate external identifier for a customer by Paid display ID. The alias shares one set of ids with customer external ids and unit ids, unique within the organization and ignoring letter case: an alias that another customer already holds as its external id, a unit id or an alias, or one another customer's signals named as a unit id that customer has not created yet, is refused with `409 EXTERNAL_ID_IN_USE` (an exact match keeps its older code, `ALIAS_CONFLICTS_WITH_CUSTOMER_EXTERNAL_ID` or `CUSTOMER_ALIAS_ALREADY_EXISTS`).

Reference: https://docs.paid.ai/api-reference/api-reference/customers/create-customer-alias

## Authentication

- `Authorization` header (bearer token, required) — API Key authentication using Bearer token

## Request

### Path parameters

- `id` (string, required) — Paid customer display id

### Body (application/json)

This endpoint expects a CustomerAliasCreateRequest.

- `alias` (string, required) — Alternate external identifier that should resolve to this customer.
- `name` (string, optional) — Optional display name for this alias.
- `description` (string, optional) — Optional note describing where this alias comes from.

## Response

### 201

201

- `alias` (string, required) — Alternate external identifier that resolves to the customer.
- `customerId` (string, required) — Paid customer display ID this alias resolves to.
- `customerUnitExternalId` (string, required, nullable) — Your id of the customer unit signals carrying this alias land on: the unit the alias was created under, or the customer's root unit for a customer-level alias. `null` only while the customer has no root unit.
- `name` (string, required, nullable)
- `description` (string, required, nullable)
- `createdAt` (datetime, required)
- `updatedAt` (datetime, required)

## Errors

### 400 Bad Request Error

400

- `error` (string, required)
- `code` (string, optional)
- `details` (string, optional)

### 403 Forbidden Error

403

- `error` (string, required)
- `code` (string, optional)
- `details` (string, optional)

### 404 Not Found Error

404

- `error` (string, required)
- `code` (string, optional)
- `details` (string, optional)

### 409 Conflict Error

409

- `error` (string, required)
- `code` (string, optional)
- `details` (string, optional)

### 500 Internal Server Error

500

- `error` (string, required)
- `code` (string, optional)
- `details` (string, optional)

## Examples

**Request**

```json
{
  "alias": "child-customer-1"
}
```

**Response**

```json
{
  "alias": "child-customer-1",
  "customerId": "cus_abc123",
  "customerUnitExternalId": "team-research",
  "name": "string",
  "description": "string",
  "createdAt": "2024-01-15T09:30:00Z",
  "updatedAt": "2024-01-15T09:30:00Z"
}
```

**SDK Code**

```python
import requests

url = "https://api.agentpaid.io/api/v2/customers/cus_abc123/aliases"

payload = { "alias": "child-customer-1" }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.agentpaid.io/api/v2/customers/cus_abc123/aliases';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"alias":"child-customer-1"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.agentpaid.io/api/v2/customers/cus_abc123/aliases"

	payload := strings.NewReader("{\n  \"alias\": \"child-customer-1\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.agentpaid.io/api/v2/customers/cus_abc123/aliases")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"alias\": \"child-customer-1\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.agentpaid.io/api/v2/customers/cus_abc123/aliases")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"alias\": \"child-customer-1\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.agentpaid.io/api/v2/customers/cus_abc123/aliases', [
  'body' => '{
  "alias": "child-customer-1"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.agentpaid.io/api/v2/customers/cus_abc123/aliases");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"alias\": \"child-customer-1\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["alias": "child-customer-1"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentpaid.io/api/v2/customers/cus_abc123/aliases")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```