openapi: 3.0.3
info:
title: Admin Account / Address Customers API
contact:
name: Spree Commerce
url: https://spreecommerce.org
email: hello@spreecommerce.org
description: "Spree Admin API v3 - Administrative API for managing products, orders, and store settings.\n\n## Authentication\n\nThe Admin API requires a secret API key passed in the `x-spree-api-key` header.\nSecret API keys can be generated in the Spree admin dashboard.\n\n## Response Format\n\nAll responses are JSON. List endpoints return paginated responses with `data` and `meta` keys.\nSingle resource endpoints return a flat JSON object.\n\n## Resource IDs\n\nEvery resource is identified by an opaque string ID (e.g. `prod_86Rf07xd4z`,\n`variant_k5nR8xLq`, `or_UkLWZg9DAJ`). Use these IDs everywhere — URL paths,\nrequest bodies, and Ransack filters all accept them directly.\n\n## Error Handling\n\nErrors return a consistent format:\n```json\n{\n \"error\": {\n \"code\": \"validation_error\",\n \"message\": \"Validation failed\",\n \"details\": { \"name\": [\"can't be blank\"] }\n }\n}\n```\n"
version: v3
servers:
- url: http://{defaultHost}
variables:
defaultHost:
default: localhost:3000
tags:
- name: Customers
description: Customer management — profiles, addresses, store credits, credit cards
paths:
/api/v3/admin/customer_groups:
get:
summary: List customer groups
tags:
- Customers
security:
- api_key: []
bearer_auth: []
description: 'Returns the customer groups configured for the current store. Groups
segment customers for targeted promotions (see the `customer_group`
promotion rule) and reporting. The list endpoint never embeds the
member list — fetch a single group with `?expand=customers` if you
need them inline, or query `/admin/customers?customer_group_id_in=…`
for paginated membership.
**Required scope:** `read_customers` (for API-key authentication).'
x-codeSamples:
- lang: javascript
label: Spree Admin SDK
source: "import { createAdminClient } from '@spree/admin-sdk'\n\nconst client = createAdminClient({\n baseUrl: 'https://your-store.com',\n secretKey: 'sk_xxx',\n})\n\nconst { data: groups } = await client.customerGroups.list({ page: 1, limit: 25 })"
parameters:
- name: x-spree-api-key
in: header
required: true
schema:
type: string
- name: Authorization
in: header
required: true
description: Bearer token for admin authentication
schema:
type: string
- name: page
in: query
required: false
description: Page number
schema:
type: integer
- name: limit
in: query
required: false
description: Number of records per page
schema:
type: integer
- name: q[name_cont]
in: query
required: false
description: Filter by name (contains)
schema:
type: string
- name: sort
in: query
required: false
description: Sort by field. Prefix with `-` for descending (e.g., `-created_at`).
schema:
type: string
- name: fields
in: query
required: false
description: Comma-separated list of fields to include. id is always included.
schema:
type: string
responses:
'200':
description: customer groups found
content:
application/json:
example:
data:
- id: cg_UkLWZg9DAJ
name: VIPs
description: Top spenders
customers_count: 0
created_at: '2026-05-24T17:36:38.239Z'
updated_at: '2026-05-24T17:36:38.239Z'
- id: cg_gbHJdmfrXB
name: Wholesale
description: null
customers_count: 0
created_at: '2026-05-24T17:36:38.240Z'
updated_at: '2026-05-24T17:36:38.240Z'
meta:
page: 1
limit: 25
count: 2
pages: 1
from: 1
to: 2
in: 2
previous: null
next: null
schema:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/CustomerGroup'
meta:
$ref: '#/components/schemas/PaginationMeta'
required:
- data
- meta
'401':
description: unauthorized
content:
application/json:
example:
error:
code: authentication_required
message: Authentication required
schema:
$ref: '#/components/schemas/ErrorResponse'
post:
summary: Create a customer group
tags:
- Customers
security:
- api_key: []
bearer_auth: []
description: 'Creates a customer group in the current store. `customer_ids` is
optional; when present, customers are attached at create time.
Pass prefixed IDs (e.g. `cus_…`) — the server decodes them
automatically.
**Required scope:** `write_customers` (for API-key authentication).'
x-codeSamples:
- lang: javascript
label: Spree Admin SDK
source: "import { createAdminClient } from '@spree/admin-sdk'\n\nconst client = createAdminClient({\n baseUrl: 'https://your-store.com',\n secretKey: 'sk_xxx',\n})\n\nconst group = await client.customerGroups.create({\n name: 'VIP customers',\n description: 'Top spenders, eligible for early access',\n customer_ids: ['cus_UkLWZg9DAJ', 'cus_QrLWXg9CAJ'],\n})"
parameters:
- name: x-spree-api-key
in: header
required: true
schema:
type: string
- name: Authorization
in: header
required: true
schema:
type: string
responses:
'201':
description: customer group created
content:
application/json:
example:
id: cg_EfhxLZ9ck8
name: Wholesale 2
description: B2B accounts
customers_count: 1
created_at: '2026-05-24T17:36:39.101Z'
updated_at: '2026-05-24T17:36:39.101Z'
schema:
$ref: '#/components/schemas/CustomerGroup'
'422':
description: validation error
content:
application/json:
example:
error:
code: validation_error
message: Name can't be blank
details:
name:
- can't be blank
schema:
$ref: '#/components/schemas/ErrorResponse'
requestBody:
content:
application/json:
schema:
type: object
required:
- name
properties:
name:
type: string
example: Wholesale
description:
type: string
example: B2B accounts
nullable: true
customer_ids:
type: array
items:
type: string
example:
- cus_UkLWZg9DAJ
/api/v3/admin/customer_groups/{id}:
parameters:
- name: id
in: path
required: true
description: Customer group prefixed ID
schema:
type: string
get:
summary: Get a customer group
tags:
- Customers
security:
- api_key: []
bearer_auth: []
description: 'Returns a single customer group. Pass `?expand=customers` to embed
the full member list inline (recommended only for single-record
reads — embed cost scales with membership size).
**Required scope:** `read_customers` (for API-key authentication).'
x-codeSamples:
- lang: javascript
label: Spree Admin SDK
source: "import { createAdminClient } from '@spree/admin-sdk'\n\nconst client = createAdminClient({\n baseUrl: 'https://your-store.com',\n secretKey: 'sk_xxx',\n})\n\n// Pass `expand: ['customers']` to embed the group's customers in the response\n// — omit it for the much smaller index-payload shape.\nconst group = await client.customerGroups.get('cg_UkLWZg9DAJ', { expand: ['customers'] })"
parameters:
- name: x-spree-api-key
in: header
required: true
schema:
type: string
- name: Authorization
in: header
required: true
schema:
type: string
- name: expand
in: query
required: false
description: 'Comma-separated associations to embed. Supported: `customers`.'
schema:
type: string
- name: fields
in: query
required: false
description: Comma-separated list of fields to include. id is always included.
schema:
type: string
responses:
'200':
description: customer group with embedded customers
content:
application/json:
example:
id: cg_UkLWZg9DAJ
name: VIPs
description: Top spenders
customers_count: 1
created_at: '2026-05-24T17:36:39.681Z'
updated_at: '2026-05-24T17:36:39.681Z'
customers:
- id: cus_UkLWZg9DAJ
email: paola_balistreri@dicki.com
first_name: Janett
last_name: Marvin
phone: null
accepts_email_marketing: false
full_name: Janett Marvin
available_store_credit_total: '0'
display_available_store_credit_total: $0.00
login: paola_balistreri@dicki.com
metadata: {}
last_sign_in_at: null
current_sign_in_at: null
created_at: '2026-05-24T17:36:39.940Z'
updated_at: '2026-05-24T17:36:39.940Z'
sign_in_count: 0
failed_attempts: 0
last_sign_in_ip: null
current_sign_in_ip: null
tags: []
internal_note_html: null
default_billing_address_id: null
default_shipping_address_id: null
orders_count: 0
total_spent: '0.0'
display_total_spent: $0.00
last_order_completed_at: null
schema:
$ref: '#/components/schemas/CustomerGroup'
'404':
description: customer group not found
content:
application/json:
example:
error:
code: record_not_found
message: Customer group not found
schema:
$ref: '#/components/schemas/ErrorResponse'
patch:
summary: Update a customer group
tags:
- Customers
security:
- api_key: []
bearer_auth: []
description: 'Updates name, description, or membership. `customer_ids` is a
full-set replacement — the server reconciles the membership to
match the array, adding new IDs and removing ones not present.
Send `customer_ids: []` to clear all members.
**Required scope:** `write_customers` (for API-key authentication).'
x-codeSamples:
- lang: javascript
label: Spree Admin SDK
source: "import { createAdminClient } from '@spree/admin-sdk'\n\nconst client = createAdminClient({\n baseUrl: 'https://your-store.com',\n secretKey: 'sk_xxx',\n})\n\n// `customer_ids` is a full-set update — the model reconciles the membership\n// to match the array (adds new IDs, removes ones not present).\nconst group = await client.customerGroups.update('cg_UkLWZg9DAJ', {\n name: 'VIP customers (Q1)',\n customer_ids: ['cus_UkLWZg9DAJ'],\n})"
parameters:
- name: x-spree-api-key
in: header
required: true
schema:
type: string
- name: Authorization
in: header
required: true
schema:
type: string
responses:
'200':
description: customer group updated
content:
application/json:
example:
id: cg_UkLWZg9DAJ
name: VIP customers (Q1)
description: Top spenders
customers_count: 0
created_at: '2026-05-24T17:36:40.533Z'
updated_at: '2026-05-24T17:36:40.811Z'
schema:
$ref: '#/components/schemas/CustomerGroup'
'422':
description: validation error
content:
application/json:
example:
error:
code: validation_error
message: Name can't be blank
details:
name:
- can't be blank
schema:
$ref: '#/components/schemas/ErrorResponse'
requestBody:
content:
application/json:
schema:
type: object
properties:
name:
type: string
example: VIP customers (Q1)
description:
type: string
example: Updated description
nullable: true
customer_ids:
type: array
items:
type: string
example:
- cus_UkLWZg9DAJ
delete:
summary: Delete a customer group
tags:
- Customers
security:
- api_key: []
bearer_auth: []
description: 'Soft-deletes the group. Member users are not deleted; their `customer_group_users` rows are dropped.
**Required scope:** `write_customers` (for API-key authentication).'
x-codeSamples:
- lang: javascript
label: Spree Admin SDK
source: "import { createAdminClient } from '@spree/admin-sdk'\n\nconst client = createAdminClient({\n baseUrl: 'https://your-store.com',\n secretKey: 'sk_xxx',\n})\n\nawait client.customerGroups.delete('cg_UkLWZg9DAJ')"
parameters:
- name: x-spree-api-key
in: header
required: true
schema:
type: string
- name: Authorization
in: header
required: true
schema:
type: string
responses:
'204':
description: customer group deleted
/api/v3/admin/customers/{customer_id}/addresses:
get:
summary: List customer addresses
tags:
- Customers
security:
- api_key: []
bearer_auth: []
description: 'Returns the customer''s saved addresses.
**Required scope:** `read_customers` (for API-key authentication).'
x-codeSamples:
- lang: javascript
label: Spree Admin SDK
source: "import { createAdminClient } from '@spree/admin-sdk'\n\nconst client = createAdminClient({\n baseUrl: 'https://your-store.com',\n secretKey: 'sk_xxx',\n})\n\nconst { data: addresses } = await client.customers.addresses.list('cus_UkLWZg9DAJ')"
parameters:
- name: x-spree-api-key
in: header
required: true
schema:
type: string
- name: Authorization
in: header
required: true
schema:
type: string
- name: customer_id
in: path
required: true
schema:
type: string
- name: expand
in: query
required: false
description: Comma-separated associations to expand (e.g., country, state). Use dot notation for nested expand (max 4 levels).
schema:
type: string
- name: fields
in: query
required: false
description: Comma-separated list of fields to include (e.g., first_name,last_name,address1,city). id is always included.
schema:
type: string
responses:
'200':
description: addresses found
content:
application/json:
example:
data:
- id: addr_UkLWZg9DAJ
first_name: John
last_name: Doe
full_name: John Doe
address1: 1 Lovely Street
address2: Northwest
postal_code: '10118'
city: New York
phone: 555-555-0199
company: Company
country_name: United States of America
country_iso: US
state_text: NY
state_abbr: NY
quick_checkout: false
is_default_billing: false
is_default_shipping: false
state_name: New York
label: null
metadata: {}
created_at: '2026-05-24T17:36:41.658Z'
updated_at: '2026-05-24T17:36:41.658Z'
customer_id: cus_UkLWZg9DAJ
meta:
page: 1
limit: 25
count: 1
pages: 1
from: 1
to: 1
in: 1
previous: null
next: null
post:
summary: Create a customer address
tags:
- Customers
security:
- api_key: []
bearer_auth: []
description: 'Adds a new address to the customer''s address book. Pass `is_default_billing: true` or `is_default_shipping: true` to set as the default — the previous default loses its flag in the same transaction.
**Required scope:** `write_customers` (for API-key authentication).'
x-codeSamples:
- lang: javascript
label: Spree Admin SDK
source: "import { createAdminClient } from '@spree/admin-sdk'\n\nconst client = createAdminClient({\n baseUrl: 'https://your-store.com',\n secretKey: 'sk_xxx',\n})\n\nconst address = await client.customers.addresses.create('cus_UkLWZg9DAJ', {\n first_name: 'Jane',\n last_name: 'Doe',\n address1: '350 Fifth Avenue',\n city: 'New York',\n postal_code: '10118',\n country_iso: 'US',\n state_abbr: 'NY',\n phone: '+1 212 555 1234',\n label: 'Office',\n is_default_shipping: true,\n})"
parameters:
- name: x-spree-api-key
in: header
required: true
schema:
type: string
- name: Authorization
in: header
required: true
schema:
type: string
- name: customer_id
in: path
required: true
schema:
type: string
responses:
'201':
description: address created
content:
application/json:
example:
id: addr_gbHJdmfrXB
first_name: Jane
last_name: Doe
full_name: Jane Doe
address1: 350 Fifth Avenue
address2: null
postal_code: '10118'
city: New York
phone: '+12125551234'
company: null
country_name: United States of America
country_iso: US
state_text: NY
state_abbr: NY
quick_checkout: false
is_default_billing: false
is_default_shipping: false
state_name: New York
label: Office
metadata: {}
created_at: '2026-05-24T17:36:43.149Z'
updated_at: '2026-05-24T17:36:43.149Z'
customer_id: cus_UkLWZg9DAJ
requestBody:
content:
application/json:
schema:
type: object
properties:
first_name:
type: string
last_name:
type: string
address1:
type: string
address2:
type: string
city:
type: string
postal_code:
type: string
country_iso:
type: string
description: ISO-2 country code (e.g. US)
state_abbr:
type: string
description: State/province abbreviation (e.g. NY)
phone:
type: string
company:
type: string
label:
type: string
is_default_billing:
type: boolean
is_default_shipping:
type: boolean
/api/v3/admin/customers/{customer_id}/addresses/{id}:
patch:
summary: Update a customer address
tags:
- Customers
security:
- api_key: []
bearer_auth: []
description: 'Updates a customer address.
**Required scope:** `write_customers` (for API-key authentication).'
x-codeSamples:
- lang: javascript
label: Spree Admin SDK
source: "import { createAdminClient } from '@spree/admin-sdk'\n\nconst client = createAdminClient({\n baseUrl: 'https://your-store.com',\n secretKey: 'sk_xxx',\n})\n\nconst address = await client.customers.addresses.update(\n 'cus_UkLWZg9DAJ',\n 'addr_UkLWZg9DAJ',\n { city: 'Manhattan' },\n)"
parameters:
- name: x-spree-api-key
in: header
required: true
schema:
type: string
- name: Authorization
in: header
required: true
schema:
type: string
- name: customer_id
in: path
required: true
schema:
type: string
- name: id
in: path
required: true
schema:
type: string
responses:
'200':
description: address updated
content:
application/json:
example:
id: addr_UkLWZg9DAJ
first_name: John
last_name: Doe
full_name: John Doe
address1: 3 Lovely Street
address2: Northwest
postal_code: '10118'
city: Manhattan
phone: 555-555-0199
company: Company
country_name: United States of America
country_iso: US
state_text: NY
state_abbr: NY
quick_checkout: false
is_default_billing: false
is_default_shipping: false
state_name: New York
label: null
metadata: {}
created_at: '2026-05-24T17:36:43.466Z'
updated_at: '2026-05-24T17:36:44.249Z'
customer_id: cus_UkLWZg9DAJ
requestBody:
content:
application/json:
schema:
type: object
properties:
city:
type: string
is_default_billing:
type: boolean
is_default_shipping:
type: boolean
delete:
summary: Delete a customer address
tags:
- Customers
security:
- api_key: []
bearer_auth: []
description: 'Deletes the address. If it was a default, the customer loses that default (no auto-promotion).
**Required scope:** `write_customers` (for API-key authentication).'
x-codeSamples:
- lang: javascript
label: Spree Admin SDK
source: "import { createAdminClient } from '@spree/admin-sdk'\n\nconst client = createAdminClient({\n baseUrl: 'https://your-store.com',\n secretKey: 'sk_xxx',\n})\n\nawait client.customers.addresses.delete('cus_UkLWZg9DAJ', 'addr_UkLWZg9DAJ')"
parameters:
- name: x-spree-api-key
in: header
required: true
schema:
type: string
- name: Authorization
in: header
required: true
schema:
type: string
- name: customer_id
in: path
required: true
schema:
type: string
- name: id
in: path
required: true
schema:
type: string
responses:
'204':
description: address deleted
/api/v3/admin/customers/{customer_id}/credit_cards:
get:
summary: List customer credit cards
tags:
- Customers
security:
- api_key: []
bearer_auth: []
description: 'Returns the customer''s saved credit cards. Useful for off-session admin charges via `POST /admin/orders/:id/payments { source_id }`.
**Required scope:** `read_customers` (for API-key authentication).'
x-codeSamples:
- lang: javascript
label: Spree Admin SDK
source: "import { createAdminClient } from '@spree/admin-sdk'\n\nconst client = createAdminClient({\n baseUrl: 'https://your-store.com',\n secretKey: 'sk_xxx',\n})\n\nconst { data: cards } = await client.customers.creditCards.list('cus_UkLWZg9DAJ')"
parameters:
- name: x-spree-api-key
in: header
required: true
schema:
type: string
- name: Authorization
in: header
required: true
schema:
type: string
- name: customer_id
in: path
required: true
schema:
type: string
- name: expand
in: query
required: false
description: Comma-separated associations to expand (e.g., payment_method). Use dot notation for nested expand (max 4 levels).
schema:
type: string
- name: fields
in: query
required: false
description: Comma-separated list of fields to include (e.g., brand,last4,month,year). id is always included.
schema:
type: string
responses:
'200':
description: credit cards found
content:
application/json:
example:
data:
- id: card_UkLWZg9DAJ
brand: visa
last4: '1111'
month: 12
year: 2027
name: Spree Commerce
default: false
gateway_payment_profile_id: null
customer_id: cus_UkLWZg9DAJ
payment_method_id: pm_UkLWZg9DAJ
metadata: {}
created_at: '2026-05-24T17:36:45.523Z'
updated_at: '2026-05-24T17:36:45.523Z'
meta:
page: 1
limit: 25
count: 1
pages: 1
from: 1
to: 1
in: 1
previous: null
next: null
/api/v3/admin/customers/{customer_id}/credit_cards/{id}:
get:
summary: Show a customer credit card
tags:
- Customers
security:
- api_key: []
bearer_auth: []
description: 'Returns a saved credit card by ID.
**Required scope:** `read_customers` (for API-key authentication).'
x-codeSamples:
- lang: javascript
label: Spree Admin SDK
source: "import { createAdminClient } from '@spree/admin-sdk'\n\nconst client = createAdminClient({\n baseUrl: 'https://your-store.com',\n secretKey: 'sk_xxx',\n})\n\nconst card = await client.customers.creditCards.get('cus_UkLWZg9DAJ', 'cc_UkLWZg9DAJ')"
parameters:
- name: x-spree-api-key
in: header
required: true
schema:
type: string
- name: Authorization
in: header
required: true
schema:
type: string
- name: customer_id
in: path
required: true
schema:
type: string
- name: id
in: path
required: true
schema:
type: string
- name: expand
in: query
required: false
description: Comma-separated associations to expand (e.g., payment_method). Use dot notation for nested expand (max 4 levels).
schema:
type: string
- name: fields
in: query
required: false
description: Comma-separated list of fields to include (e.g., brand,last4,month,year). id is always included.
schema:
type: string
responses:
'200':
description: credit card found
content:
application/json:
example:
id: card_UkLWZg9DAJ
brand: visa
last4: '1111'
month: 12
year: 2027
name: Spree Commerce
default: false
gateway_payment_profile_id: null
customer_id: cus_UkLWZg9DAJ
payment_method_id: pm_UkLWZg9DAJ
metadata: {}
created_at: '2026-05-24T17:36:46.077Z'
updated_at: '2026-05-24T17:36:46.077Z'
delete:
summary: Delete a customer credit card
tags:
- Customers
security:
- api_key: []
bearer_auth: []
description: 'Deletes a saved credit card.
**Required scope:** `write_customers` (for API-key authentication).'
x-codeSamples:
- lang: javascript
label: Spree Admin SDK
source: "import { createAdminClient } from '@spree/admin-sdk'\n\nconst client = createAdminClient({\n baseUrl: 'https://your-store.com',\n secretKey: 'sk_xxx',\n})\n\nawait client.customers.creditCards.delete('cus_UkLWZg9DAJ', 'cc_UkLWZg9DAJ')"
parameters:
- name: x-spree-api-key
in: header
required: true
schema:
type: string
- name: Authorization
in: header
required: true
schema:
type: string
- name: customer_id
in: path
required: true
schema:
type: string
- name: id
in: path
required: true
schema:
type: string
responses:
'204':
description: credit card deleted
/api/v3/admin/customers/{customer_id}/store_credits:
get:
summary: List customer store credits
tags:
- Customers
security:
- api_key: []
bearer_auth: []
description: 'Returns store credits issued to the customer.
**Required scope:** `read_store_credits` (for API-key authentication).'
x-codeSamples:
- lang: javascript
label: Spree Admin SDK
source: "import { createAdminClient } from '@spree/admin-sdk'\n\nconst client = createAdminClient({\n baseUrl: 'https://your-store.com',\n secretKey: 'sk_xxx',\n})\n\nconst { data: storeCredits } = await client.customers.storeCredits.list('cus_UkLWZg9DAJ')"
parameters:
- name: x-spree-api-key
in: header
required: true
schema:
type: string
- name: Authorization
in: header
required: true
schema:
type: string
- name: customer_id
in: path
required: true
schema:
type: string
- name: expand
in: query
required: false
description: Comma-separated associations to expand (e.g., category, store, created_by). Use dot notation for nested expand (max 4 levels).
schema:
type: string
- name: fields
in: query
required: false
description: Comma-separated list of fields to include (e.g., amount,amount_used,memo,currency). id is always included.
schema:
type: string
responses:
'200':
description: store credits found
content:
application/json:
example:
data:
- id: credit_UkLWZg9DAJ
amount: '50.0'
amount_used: '0.0'
# --- truncated at 32 KB (201 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/spree-commerce/refs/heads/main/openapi/spree-commerce-customers-api-openapi.yml