> 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.

# Update customer

PATCH https://api.md.tiankii.com/v1/customers/{id}
Content-Type: application/json

## Update customer

Partially updates an existing customer identified by `id`, scoped to the authenticated store. All body fields are optional (PartialType of the create DTO) — only supplied fields are updated.

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

### Path params
- `id`: the customer UUID (must belong to the caller's store).

### Body
JSON body (`application/json`) with any subset of the customer fields. Unknown properties are stripped.

### Side-effects / validation
- If the customer is not found for the store: **404 Not Found**.
- If `email` is changed to one already used by another customer in the same store (case-insensitive): **400 Bad Request** (`"A customer with this email already exists for your store."`).
- Returns the updated customer record.

---
**Notas:** PartialType(CreateCustomerDto) — every create field is accepted but optional. Email uniqueness is only re-checked when the email actually changes. 404 if the customer does not belong to the caller's store.

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

## Authentication

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

## Request

### Path parameters

- `id` (string, required) — The customer's unique identifier (UUID). Must belong to the authenticated store.

### 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, optional)
- `email` (string, optional)
- `mobile` (string, optional)

## Examples

**Request**

```json
{
  "name": "Alice J. Johnson",
  "email": "alice.new@example.com",
  "mobile": "+14155559999"
}
```

**SDK Code**

```python
import requests

url = "https://api.md.tiankii.com/v1/customers/3f2504e0-4f89-41d3-9a0c-0305e82c3301"

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

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

print(response.json())
```

```javascript
const url = 'https://api.md.tiankii.com/v1/customers/3f2504e0-4f89-41d3-9a0c-0305e82c3301';
const options = {
  method: 'PATCH',
  headers: {
    'x-application-account-id': 'acct_3f9a21c7',
    'x-api-key': '<apiKey>',
    'Content-Type': 'application/json'
  },
  body: '{"name":"Alice J. Johnson","email":"alice.new@example.com","mobile":"+14155559999"}'
};

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/3f2504e0-4f89-41d3-9a0c-0305e82c3301"

	payload := strings.NewReader("{\n  \"name\": \"Alice J. Johnson\",\n  \"email\": \"alice.new@example.com\",\n  \"mobile\": \"+14155559999\"\n}")

	req, _ := http.NewRequest("PATCH", 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/3f2504e0-4f89-41d3-9a0c-0305e82c3301")

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

request = Net::HTTP::Patch.new(url)
request["x-application-account-id"] = 'acct_3f9a21c7'
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"Alice J. Johnson\",\n  \"email\": \"alice.new@example.com\",\n  \"mobile\": \"+14155559999\"\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.patch("https://api.md.tiankii.com/v1/customers/3f2504e0-4f89-41d3-9a0c-0305e82c3301")
  .header("x-application-account-id", "acct_3f9a21c7")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"Alice J. Johnson\",\n  \"email\": \"alice.new@example.com\",\n  \"mobile\": \"+14155559999\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.md.tiankii.com/v1/customers/3f2504e0-4f89-41d3-9a0c-0305e82c3301', [
  'body' => '{
  "name": "Alice J. Johnson",
  "email": "alice.new@example.com",
  "mobile": "+14155559999"
}',
  '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/3f2504e0-4f89-41d3-9a0c-0305e82c3301");
var request = new RestRequest(Method.PATCH);
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 J. Johnson\",\n  \"email\": \"alice.new@example.com\",\n  \"mobile\": \"+14155559999\"\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 J. Johnson",
  "email": "alice.new@example.com",
  "mobile": "+14155559999"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.md.tiankii.com/v1/customers/3f2504e0-4f89-41d3-9a0c-0305e82c3301")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
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()
```