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

# Create customer

POST https://api.md.tiankii.com/v1/customers
Content-Type: application/json

## Create customer

Creates a new customer record scoped to the authenticated merchant's store. The `storeId` is derived from the API key context (not supplied in the body), and a UUID `id` is generated server-side.

### Authentication
- Send the merchant API key in the **`x-api-key`** header (alias `x-account-api-key`).
- Requires the scope: **`Merchant.customer.create`**.
- Optionally scope the key to a specific store/account with the **`x-application-account-id`** header (alias `x-account-id`) or the `application_account_id` / `account_id` query param.

### Body
JSON body (`application/json`). Only `name` and `email` are required. The optional fields accepted by `CreateCustomerDto` are `mobile`, `addressLine1`, `addressLine2`, `city`, `state`, `postalCode` and `country`. Unknown properties are stripped by the validation pipe.

### Side-effects / validation
- Email must be unique **per store** (case-insensitive). If a customer with the same email already exists for the store, the request fails with **400 Bad Request** (`"A customer with this email already exists for your store."`).
- Returns the full persisted customer record on success.

---
**Notas:** storeId and id are set server-side and cannot be supplied by the client. Email uniqueness is enforced per store (case-insensitive) and returns 400 on conflict. Related endpoints: GET /v1/customers, PATCH /v1/customers/:id.

Reference: https://docs.tiankii.com/api-reference/tiankii-api-api-key/customers/create

## Authentication

- `x-api-key` header (required)

## Request

### Headers

- `x-application-account-id` (string, optional) — Scope the request to a specific store / account instead of the one resolved from the API key. Aliases: the `x-account-id` header, or the `application_account_id` / `account_id` query parameter.

### Body (application/json)

- `name` (string, required)
- `email` (string, required)

## Examples

**Request**

```json
{
  "name": "Alice Johnson",
  "email": "alice.johnson@example.com"
}
```

**SDK Code**

```python
import requests

url = "https://api.md.tiankii.com/v1/customers"

payload = {
    "name": "Alice Johnson",
    "email": "alice.johnson@example.com"
}
headers = {
    "x-application-account-id": "acct_3f9a21c7",
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api.md.tiankii.com/v1/customers';
const options = {
  method: 'POST',
  headers: {
    'x-application-account-id': 'acct_3f9a21c7',
    'x-api-key': '<apiKey>',
    'Content-Type': 'application/json'
  },
  body: '{"name":"Alice Johnson","email":"alice.johnson@example.com"}'
};

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.md.tiankii.com/v1/customers"

	payload := strings.NewReader("{\n  \"name\": \"Alice Johnson\",\n  \"email\": \"alice.johnson@example.com\"\n}")

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

	req.Header.Add("x-application-account-id", "acct_3f9a21c7")
	req.Header.Add("x-api-key", "<apiKey>")
	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.md.tiankii.com/v1/customers")

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

request = Net::HTTP::Post.new(url)
request["x-application-account-id"] = 'acct_3f9a21c7'
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"Alice Johnson\",\n  \"email\": \"alice.johnson@example.com\"\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.md.tiankii.com/v1/customers")
  .header("x-application-account-id", "acct_3f9a21c7")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"Alice Johnson\",\n  \"email\": \"alice.johnson@example.com\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.md.tiankii.com/v1/customers', [
  'body' => '{
  "name": "Alice Johnson",
  "email": "alice.johnson@example.com"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
    'x-application-account-id' => 'acct_3f9a21c7',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.md.tiankii.com/v1/customers");
var request = new RestRequest(Method.POST);
request.AddHeader("x-application-account-id", "acct_3f9a21c7");
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"Alice Johnson\",\n  \"email\": \"alice.johnson@example.com\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "x-application-account-id": "acct_3f9a21c7",
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "Alice Johnson",
  "email": "alice.johnson@example.com"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.md.tiankii.com/v1/customers")! 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()
```