(customers)
- list - List Customers
- create - Create Customer
- get - Get Customer
- update - Update Customer
- delete - Delete Customer
- getExternal - Get Customer by External ID
- updateExternal - Update Customer by External ID
- deleteExternal - Delete Customer by External ID
- getState - Get Customer State
- getStateExternal - Get Customer State by External ID
List customers.
Scopes: customers:read
customers:write
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
use Polar\Models\Operations;
$sdk = Polar\Polar::builder()
->setSecurity(
'<YOUR_BEARER_TOKEN_HERE>'
)
->build();
$request = new Operations\CustomersListRequest(
organizationId: [
'1dbfc517-0bbf-4301-9ba8-555ca42b9737',
],
);
$responses = $sdk->customers->list(
request: $request
);
foreach ($responses as $response) {
if ($response->statusCode === 200) {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
$request |
Operations\CustomersListRequest | ✔️ | The request object to use for the request. |
?Operations\CustomersListResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\HTTPValidationError | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |
Create a customer.
Scopes: customers:write
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
use Polar\Models\Components;
$sdk = Polar\Polar::builder()
->setSecurity(
'<YOUR_BEARER_TOKEN_HERE>'
)
->build();
$request = new Components\CustomerCreate(
externalId: 'usr_1337',
email: 'customer@example.com',
name: 'John Doe',
billingAddress: new Components\Address(
country: 'SE',
),
taxId: [
'FR61954506077',
'eu_vat',
],
organizationId: '1dbfc517-0bbf-4301-9ba8-555ca42b9737',
);
$response = $sdk->customers->create(
request: $request
);
if ($response->customer !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
$request |
Components\CustomerCreate | ✔️ | The request object to use for the request. |
?Operations\CustomersCreateResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\HTTPValidationError | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |
Get a customer by ID.
Scopes: customers:read
customers:write
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
$sdk = Polar\Polar::builder()
->setSecurity(
'<YOUR_BEARER_TOKEN_HERE>'
)
->build();
$response = $sdk->customers->get(
id: '<value>'
);
if ($response->customer !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
id |
string | ✔️ | The customer ID. |
?Operations\CustomersGetResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\ResourceNotFound | 404 | application/json |
Errors\HTTPValidationError | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |
Update a customer.
Scopes: customers:write
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
use Polar\Models\Components;
$sdk = Polar\Polar::builder()
->setSecurity(
'<YOUR_BEARER_TOKEN_HERE>'
)
->build();
$customerUpdate = new Components\CustomerUpdate(
externalId: 'usr_1337',
email: 'customer@example.com',
name: 'John Doe',
billingAddress: new Components\Address(
country: 'FR',
),
taxId: [
'FR61954506077',
'eu_vat',
],
);
$response = $sdk->customers->update(
id: '<value>',
customerUpdate: $customerUpdate
);
if ($response->customer !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
id |
string | ✔️ | The customer ID. |
customerUpdate |
Components\CustomerUpdate | ✔️ | N/A |
?Operations\CustomersUpdateResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\ResourceNotFound | 404 | application/json |
Errors\HTTPValidationError | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |
Delete a customer.
This action cannot be undone and will immediately:
- Cancel any active subscriptions for the customer
- Revoke all their benefits
- Clear any
external_id
Use it only in the context of deleting a user within your own service. Otherwise, use more granular API endpoints to cancel a specific subscription or revoke certain benefits.
Note: The customers information will nonetheless be retained for historic orders and subscriptions.
Scopes: customers:write
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
$sdk = Polar\Polar::builder()
->setSecurity(
'<YOUR_BEARER_TOKEN_HERE>'
)
->build();
$response = $sdk->customers->delete(
id: '<value>'
);
if ($response->statusCode === 200) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
id |
string | ✔️ | The customer ID. |
?Operations\CustomersDeleteResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\ResourceNotFound | 404 | application/json |
Errors\HTTPValidationError | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |
Get a customer by external ID.
Scopes: customers:read
customers:write
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
$sdk = Polar\Polar::builder()
->setSecurity(
'<YOUR_BEARER_TOKEN_HERE>'
)
->build();
$response = $sdk->customers->getExternal(
externalId: '<id>'
);
if ($response->customer !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
externalId |
string | ✔️ | The customer external ID. |
?Operations\CustomersGetExternalResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\ResourceNotFound | 404 | application/json |
Errors\HTTPValidationError | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |
Update a customer by external ID.
Scopes: customers:write
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
use Polar\Models\Components;
$sdk = Polar\Polar::builder()
->setSecurity(
'<YOUR_BEARER_TOKEN_HERE>'
)
->build();
$customerUpdate = new Components\CustomerUpdate(
externalId: 'usr_1337',
email: 'customer@example.com',
name: 'John Doe',
billingAddress: new Components\Address(
country: 'US',
),
taxId: [
'FR61954506077',
'eu_vat',
],
);
$response = $sdk->customers->updateExternal(
externalId: '<id>',
customerUpdate: $customerUpdate
);
if ($response->customer !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
externalId |
string | ✔️ | The customer external ID. |
customerUpdate |
Components\CustomerUpdate | ✔️ | N/A |
?Operations\CustomersUpdateExternalResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\ResourceNotFound | 404 | application/json |
Errors\HTTPValidationError | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |
Delete a customer by external ID.
Immediately cancels any active subscriptions and revokes any active benefits.
Scopes: customers:write
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
$sdk = Polar\Polar::builder()
->setSecurity(
'<YOUR_BEARER_TOKEN_HERE>'
)
->build();
$response = $sdk->customers->deleteExternal(
externalId: '<id>'
);
if ($response->statusCode === 200) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
externalId |
string | ✔️ | The customer external ID. |
?Operations\CustomersDeleteExternalResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\ResourceNotFound | 404 | application/json |
Errors\HTTPValidationError | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |
Get a customer state by ID.
The customer state includes information about the customer's active subscriptions and benefits.
It's the ideal endpoint to use when you need to get a full overview of a customer's status.
Scopes: customers:read
customers:write
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
$sdk = Polar\Polar::builder()
->setSecurity(
'<YOUR_BEARER_TOKEN_HERE>'
)
->build();
$response = $sdk->customers->getState(
id: '<value>'
);
if ($response->customerState !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
id |
string | ✔️ | The customer ID. |
?Operations\CustomersGetStateResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\ResourceNotFound | 404 | application/json |
Errors\HTTPValidationError | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |
Get a customer state by external ID.
The customer state includes information about the customer's active subscriptions and benefits.
It's the ideal endpoint to use when you need to get a full overview of a customer's status.
Scopes: customers:read
customers:write
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
$sdk = Polar\Polar::builder()
->setSecurity(
'<YOUR_BEARER_TOKEN_HERE>'
)
->build();
$response = $sdk->customers->getStateExternal(
externalId: '<id>'
);
if ($response->customerState !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
externalId |
string | ✔️ | The customer external ID. |
?Operations\CustomersGetStateExternalResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\ResourceNotFound | 404 | application/json |
Errors\HTTPValidationError | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |