Update a Customer
Update an existing customer's information including description, email, metadata, and default card. All parameters are optional - only provide the fields you want to update.
API Credentials
Request Parametersโ
Required - 1 fieldPath Parameters
`id`STRING(required)
The customer ID to update (must start with cust_).
Additional - 4 fieldsOptional Parameters
Responsesโ
200
Customer updated successfullyCustomer object returned with updated information.
Update behavior:
- Only provided fields are updated
- Unprovided fields remain unchanged
- Metadata is merged (not replaced)
- If
cardis provided, a new card is added and becomes default - Previous cards remain attached but are no longer default
400
Bad requestRequest validation failed. Check the error message for details.
Common causes:
- Invalid email format
- Invalid metadata format
- Metadata exceeds 15,000 characters
401
UnauthorizedAuthentication failed. Invalid or missing API key.
Common causes:
- Missing Authorization header
- Invalid secret key
- Using public key instead of secret key
- Incorrect HTTP Basic Auth format
404
Not foundCustomer or token not found.
Common causes:
- Customer ID does not exist
- Token ID does not exist
- Token has already been used
Code samplesโ
- cURL
- Ruby
- Python
- Node.js
- PHP
- Java
- C#
- Go
curl https://api.omise.co/customers/cust_test_5xuy4w91xqz7d1w9u0t \
-X PATCH \
-u skey_test_5xuy4w91xqz7d1w9u0t: \
-d "email=john.updated@example.com" \
-d "description=John Doe - Premium Member"
require 'omise'
Omise.api_key = 'skey_test_5xuy4w91xqz7d1w9u0t'
customer = Omise::Customer.update('cust_test_5xuy4w91xqz7d1w9u0t', {
email: 'john.updated@example.com',
description: 'John Doe - Premium Member'
})
import omise
omise.api_secret = 'skey_test_5xuy4w91xqz7d1w9u0t'
customer = omise.Customer.retrieve('cust_test_5xuy4w91xqz7d1w9u0t')
customer.update(
email='john.updated@example.com',
description='John Doe - Premium Member'
)
const omise = require('omise')({
secretKey: 'skey_test_5xuy4w91xqz7d1w9u0t'
});
const customer = await omise.customers.update('cust_test_5xuy4w91xqz7d1w9u0t', {
email: 'john.updated@example.com',
description: 'John Doe - Premium Member'
});
<?php
define('OMISE_SECRET_KEY', 'skey_test_5xuy4w91xqz7d1w9u0t');
$customer = OmiseCustomer::retrieve('cust_test_5xuy4w91xqz7d1w9u0t');
$customer->update([
'email' => 'john.updated@example.com',
'description' => 'John Doe - Premium Member'
]);
Client client = new Client.Builder()
.secretKey("skey_test_5xuy4w91xqz7d1w9u0t")
.build();
Customer customer = client.customers().update("cust_test_5xuy4w91xqz7d1w9u0t")
.email("john.updated@example.com")
.description("John Doe - Premium Member")
.send();
var client = new Client("skey_test_5xuy4w91xqz7d1w9u0t");
var customer = await client.Customers.Update("cust_test_5xuy4w91xqz7d1w9u0t", new UpdateCustomerRequest
{
Email = "john.updated@example.com",
Description = "John Doe - Premium Member"
});
client, _ := omise.NewClient(
"pkey_test_5xuy4w91xqz7d1w9u0t",
"skey_test_5xuy4w91xqz7d1w9u0t",
)
customer, _ := client.Customers().Update("cust_test_5xuy4w91xqz7d1w9u0t", &operations.UpdateCustomer{
Email: "john.updated@example.com",
Description: "John Doe - Premium Member",
})
Error and result codesโ
Common Error Codesโ
| Code | Description | Resolution |
|---|---|---|
bad_request | Invalid parameters | Check email format and metadata |
authentication_failure | Invalid API key | Verify your secret key is correct |
not_found | Customer not found | Verify customer ID exists |
used_token | Token already used | Generate a new token |
invalid_card | Invalid card token | Check token is valid |
Update Fieldsโ
| Field | Description |
|---|---|
email | Updated customer email |
description | Updated customer description |
default_card | New default card (if card provided) |
metadata | Merged metadata object |
cards | List of all cards (includes new card if added) |
Try it outโ
Required - 1 fields
Additional - 4 fields