Skip to main content
GET
/
v1
/
customers
/
{id}
/
state
Go (SDK)
package main

import(
	"context"
	"os"
	polargo "github.com/polarsource/polar-go"
	"log"
	"github.com/polarsource/polar-go/models/components"
)

func main() {
    ctx := context.Background()

    s := polargo.New(
        polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
    )

    res, err := s.Customers.GetState(ctx, "<value>")
    if err != nil {
        log.Fatal(err)
    }
    if res.CustomerState != nil {
        switch res.CustomerState.Type {
            case components.CustomerStateTypeIndividual:
                // res.CustomerState.CustomerStateIndividual is populated
            case components.CustomerStateTypeTeam:
                // res.CustomerState.CustomerStateTeam is populated
        }

    }
}
{
  "id": "<string>",
  "created_at": "2023-11-07T05:31:56Z",
  "modified_at": "2023-11-07T05:31:56Z",
  "metadata": {},
  "email": "<string>",
  "email_verified": true,
  "type": "<string>",
  "name": "John Doe",
  "billing_address": {
    "country": "AD",
    "line1": "<string>",
    "line2": "<string>",
    "postal_code": "<string>",
    "city": "<string>",
    "state": "<string>"
  },
  "tax_id": {
    "[0]": "<string>"
  },
  "organization_id": "<string>",
  "deleted_at": "2023-11-07T05:31:56Z",
  "active_subscriptions": [
    {
      "id": "<string>",
      "created_at": "2023-11-07T05:31:56Z",
      "modified_at": "2023-11-07T05:31:56Z",
      "metadata": {},
      "status": "active",
      "amount": 123,
      "currency": "<string>",
      "recurring_interval": "day",
      "current_period_start": "2023-11-07T05:31:56Z",
      "current_period_end": "2023-11-07T05:31:56Z",
      "trial_start": "2025-02-03T13:37:00Z",
      "trial_end": "2025-03-03T13:37:00Z",
      "cancel_at_period_end": true,
      "canceled_at": null,
      "started_at": "2025-01-03T13:37:00Z",
      "ends_at": null,
      "product_id": "<string>",
      "discount_id": null,
      "meters": [
        {
          "created_at": "2023-11-07T05:31:56Z",
          "modified_at": "2023-11-07T05:31:56Z",
          "id": "<string>",
          "consumed_units": 123,
          "credited_units": 123,
          "amount": 123,
          "meter_id": "<string>"
        }
      ],
      "custom_field_data": {}
    }
  ],
  "granted_benefits": [
    {
      "id": "<string>",
      "created_at": "2023-11-07T05:31:56Z",
      "modified_at": "2023-11-07T05:31:56Z",
      "granted_at": "2023-11-07T05:31:56Z",
      "benefit_id": "<string>",
      "benefit_type": "custom",
      "benefit_metadata": {},
      "properties": {
        "account_id": "<string>",
        "guild_id": "<string>",
        "role_id": "<string>",
        "granted_account_id": "<string>"
      }
    }
  ],
  "active_meters": [
    {
      "id": "<string>",
      "created_at": "2023-11-07T05:31:56Z",
      "modified_at": "2023-11-07T05:31:56Z",
      "meter_id": "<string>",
      "consumed_units": 123,
      "credited_units": 123,
      "balance": 123
    }
  ],
  "avatar_url": "<string>",
  "external_id": "usr_1337",
  "locale": "<string>"
}

Documentation Index

Fetch the complete documentation index at: https://polar.sh/docs/llms.txt

Use this file to discover all available pages before exploring further.

Authorizations

Authorization
string
header
required

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

Path Parameters

id
string<uuid4>
required

The customer ID.

Response

Successful Response

A customer along with additional state information:

  • Active subscriptions
  • Granted benefits
  • Active meters
id
string<uuid4>
required

The ID of the customer.

Example:

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

created_at
string<date-time>
required

Creation timestamp of the object.

modified_at
string<date-time> | null
required

Last modification timestamp of the object.

metadata
object
required
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

type
string
required

The type of customer.

Allowed value: "individual"
Example:

"individual"

name
string | null
required

The name of the customer.

Example:

"John Doe"

billing_address
Address · object
required
tax_id
Tax Id · object
required
organization_id
string<uuid4>
required

The ID of the organization owning the customer.

Example:

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

deleted_at
string<date-time> | null
required

Timestamp for when the customer was soft deleted.

active_subscriptions
CustomerStateSubscription · object[]
required

The customer's active subscriptions.

granted_benefits
CustomerStateBenefitGrant · object[]
required

The customer's active benefit grants.

active_meters
CustomerStateMeter · object[]
required

The customer's active meters.

avatar_url
string
required
Example:

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

external_id
string | null

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"

locale
string | null