GET
/
v1
/
customers
/
external
/
{external_id}
/
state
import { Polar } from "@polar-sh/sdk";

const polar = new Polar({
  accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});

async function run() {
  const result = await polar.customers.getStateExternal({
    externalId: "<id>",
  });

  // Handle the result
  console.log(result);
}

run();
{
  "id": "992fae2a-2a17-4b7a-8d9e-e287cf90131b",
  "created_at": "2023-11-07T05:31:56Z",
  "modified_at": "2023-11-07T05:31:56Z",
  "metadata": {},
  "external_id": "usr_1337",
  "email": "customer@example.com",
  "email_verified": true,
  "name": "John Doe",
  "billing_address": {
    "line1": "<string>",
    "line2": "<string>",
    "postal_code": "<string>",
    "city": "<string>",
    "state": "<string>",
    "country": "US"
  },
  "tax_id": [
    "911144442",
    "us_ein"
  ],
  "organization_id": "1dbfc517-0bbf-4301-9ba8-555ca42b9737",
  "active_subscriptions": [
    {
      "id": "e5149aae-e521-42b9-b24c-abb3d71eea2e",
      "created_at": "2023-11-07T05:31:56Z",
      "modified_at": "2023-11-07T05:31:56Z",
      "custom_field_data": {},
      "metadata": {},
      "status": "active",
      "amount": 1000,
      "currency": "usd",
      "recurring_interval": "month",
      "current_period_start": "2025-02-03T13:37:00Z",
      "current_period_end": "2025-03-03T13:37:00Z",
      "cancel_at_period_end": false,
      "canceled_at": null,
      "started_at": "2025-01-03T13:37:00Z",
      "ends_at": null,
      "product_id": "d8dd2de1-21b7-4a41-8bc3-ce909c0cfe23",
      "price_id": "196ca717-4d84-4d28-a1b8-777255797dbc",
      "discount_id": null
    }
  ],
  "granted_benefits": [
    {
      "id": "d322132c-a9d0-4e0d-b8d3-d81ad021a3a9",
      "created_at": "2023-11-07T05:31:56Z",
      "modified_at": "2023-11-07T05:31:56Z",
      "granted_at": "2025-01-03T13:37:00Z",
      "benefit_id": "397a17aa-15cf-4cb4-9333-18040203cf98",
      "benefit_type": "custom",
      "properties": {
        "account_id": "<string>",
        "guild_id": "<string>",
        "role_id": "<string>"
      }
    }
  ],
  "avatar_url": "https://www.gravatar.com/avatar/xxx?d=blank"
}

Authorizations

Authorization
string
header
required

You can generate an Organization Access Token from your organization's settings.

Path Parameters

external_id
string
required

The customer external ID.

Response

200
application/json
Successful Response

A customer along with additional state information:

  • Active subscriptions
  • Active benefits
id
string
required

The ID of the customer.

Example:

"992fae2a-2a17-4b7a-8d9e-e287cf90131b"

created_at
string
required

Creation timestamp of the object.

modified_at
string | null
required

Last modification timestamp of the object.

metadata
object
required
external_id
string | null
required

The ID of the customer in your system. This must be unique within the organization. Once set, it can't be updated.

Example:

"usr_1337"

email
string
required

The email address of the customer. This must be unique within the organization.

Example:

"customer@example.com"

email_verified
boolean
required

Whether the customer email address is verified. The address is automatically verified when the customer accesses the customer portal using their email address.

Example:

true

name
string | null
required

The name of the customer.

Example:

"John Doe"

billing_address
object | null
required
tax_id
any[] | null
required
Example:
["911144442", "us_ein"]
organization_id
string
required

The ID of the organization owning the customer.

Example:

"1dbfc517-0bbf-4301-9ba8-555ca42b9737"

active_subscriptions
object[]
required

The customer's active subscriptions.

An active customer subscription.

granted_benefits
object[]
required

The customer's active benefit grants.

An active benefit grant for a customer.

avatar_url
string
required
Example:

"https://www.gravatar.com/avatar/xxx?d=blank"