For clean Markdown of any page, append .md to the page URL. For a complete documentation index, see https://docs.prolifi.io/endpoints/customers/llms.txt. For full documentation content, see https://docs.prolifi.io/endpoints/customers/llms-full.txt.

# Update a customer

PATCH https://api.prolifi.co/api/v1/public/customers/{id}
Content-Type: application/json

Updates an existing customer. Only the fields provided in the request body will be changed. The `id` parameter can be a UUID or `external_id`.


Reference: https://docs.prolifi.io/endpoints/customers/update-customer

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Prolifi Public API
  version: 1.0.0
paths:
  /customers/{id}:
    patch:
      operationId: update-customer
      summary: Update a customer
      description: >
        Updates an existing customer. Only the fields provided in the request
        body will be changed. The `id` parameter can be a UUID or `external_id`.
      tags:
        - subpackage_customers
      parameters:
        - name: id
          in: path
          description: The customer UUID or external_id.
          required: true
          schema:
            type: string
        - name: Authorization
          in: header
          description: >
            Use a secret key (`sk_test_*` or `sk_live_*`) for full read/write
            access, or a public key (`pk_test_*` or `pk_live_*`) for read-only
            access.
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Customer updated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Customers_updateCustomer_Response_200'
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Permission denied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Resource not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateCustomerRequest'
servers:
  - url: https://api.prolifi.co/api/v1/public
  - url: https://sandbox.prolifi.co/api/v1/public
components:
  schemas:
    UpdateCustomerRequestMetadata:
      type: object
      properties: {}
      title: UpdateCustomerRequestMetadata
    UpdateCustomerRequest:
      type: object
      properties:
        email:
          type:
            - string
            - 'null'
          format: email
        name:
          type:
            - string
            - 'null'
        first_name:
          type:
            - string
            - 'null'
        last_name:
          type:
            - string
            - 'null'
        company_name:
          type:
            - string
            - 'null'
        external_id:
          type:
            - string
            - 'null'
        phone:
          type:
            - string
            - 'null'
        country_id:
          type:
            - string
            - 'null'
          format: uuid
        metadata:
          oneOf:
            - $ref: '#/components/schemas/UpdateCustomerRequestMetadata'
            - type: 'null'
      title: UpdateCustomerRequest
    CustomerStatus:
      type: string
      enum:
        - active
        - archived
      title: CustomerStatus
    CustomerMetadata:
      type: object
      properties: {}
      title: CustomerMetadata
    Customer:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier.
        external_id:
          type:
            - string
            - 'null'
          description: Your application's identifier for this customer.
        email:
          type: string
          format: email
          description: Email address.
        name:
          type:
            - string
            - 'null'
          description: Full name (computed from first and last name).
        first_name:
          type:
            - string
            - 'null'
        last_name:
          type:
            - string
            - 'null'
        company_name:
          type:
            - string
            - 'null'
          description: Company name (for business customers).
        phone:
          type:
            - string
            - 'null'
        status:
          $ref: '#/components/schemas/CustomerStatus'
        country:
          type:
            - string
            - 'null'
          description: Country name.
        country_id:
          type:
            - string
            - 'null'
          format: uuid
        metadata:
          oneOf:
            - $ref: '#/components/schemas/CustomerMetadata'
            - type: 'null'
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      title: Customer
    Customers_updateCustomer_Response_200:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/Customer'
      title: Customers_updateCustomer_Response_200
    ErrorResponseErrorType:
      type: string
      enum:
        - authentication_error
        - permission_error
        - validation_error
        - not_found
        - invalid_request
        - rate_limit_error
        - ip_restricted
        - conflict
        - api_error
      description: Machine-readable error type.
      title: ErrorResponseErrorType
    ErrorResponseErrorErrorsItems:
      type: object
      properties:
        field:
          type: string
          description: The field that failed validation.
        message:
          type: string
          description: The validation error message.
      title: ErrorResponseErrorErrorsItems
    ErrorResponseError:
      type: object
      properties:
        type:
          $ref: '#/components/schemas/ErrorResponseErrorType'
          description: Machine-readable error type.
        message:
          type: string
          description: Human-readable error description.
        errors:
          type: array
          items:
            $ref: '#/components/schemas/ErrorResponseErrorErrorsItems'
          description: >-
            Field-level validation errors (only present for `validation_error`
            type).
      required:
        - type
        - message
      title: ErrorResponseError
    ErrorResponse:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/ErrorResponseError'
      title: ErrorResponse
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >
        Use a secret key (`sk_test_*` or `sk_live_*`) for full read/write
        access, or a public key (`pk_test_*` or `pk_live_*`) for read-only
        access.

```

## SDK Code Examples

```python Update name
import requests

url = "https://api.prolifi.co/api/v1/public/customers/id"

payload = {
    "first_name": "Jane",
    "last_name": "Doe"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Update name
const url = 'https://api.prolifi.co/api/v1/public/customers/id';
const options = {
  method: 'PATCH',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"first_name":"Jane","last_name":"Doe"}'
};

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

```go Update name
package main

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

func main() {

	url := "https://api.prolifi.co/api/v1/public/customers/id"

	payload := strings.NewReader("{\n  \"first_name\": \"Jane\",\n  \"last_name\": \"Doe\"\n}")

	req, _ := http.NewRequest("PATCH", 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 Update name
require 'uri'
require 'net/http'

url = URI("https://api.prolifi.co/api/v1/public/customers/id")

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

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"first_name\": \"Jane\",\n  \"last_name\": \"Doe\"\n}"

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

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

HttpResponse<String> response = Unirest.patch("https://api.prolifi.co/api/v1/public/customers/id")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"first_name\": \"Jane\",\n  \"last_name\": \"Doe\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.prolifi.co/api/v1/public/customers/id', [
  'body' => '{
  "first_name": "Jane",
  "last_name": "Doe"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Update name
using RestSharp;

var client = new RestClient("https://api.prolifi.co/api/v1/public/customers/id");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"first_name\": \"Jane\",\n  \"last_name\": \"Doe\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Update name
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "first_name": "Jane",
  "last_name": "Doe"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.prolifi.co/api/v1/public/customers/id")! 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()
```

```python
import requests

url = "https://api.prolifi.co/api/v1/public/customers/id"

payload = { "email": "newemail@example.com" }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api.prolifi.co/api/v1/public/customers/id';
const options = {
  method: 'PATCH',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"email":"newemail@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.prolifi.co/api/v1/public/customers/id"

	payload := strings.NewReader("{\n  \"email\": \"newemail@example.com\"\n}")

	req, _ := http.NewRequest("PATCH", 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.prolifi.co/api/v1/public/customers/id")

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

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"email\": \"newemail@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.patch("https://api.prolifi.co/api/v1/public/customers/id")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"email\": \"newemail@example.com\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.prolifi.co/api/v1/public/customers/id', [
  'body' => '{
  "email": "newemail@example.com"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.prolifi.co/api/v1/public/customers/id");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"email\": \"newemail@example.com\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["email": "newemail@example.com"] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.prolifi.co/api/v1/public/customers/id")! 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()
```