Quickstart
Create an API key and make your first request to the VYG API.
Create an API key and retrieve your top five customers by total spend.
1. Create an API key
-
Sign in to VYG as a brand admin. Open Settings → API Keys for a VYG API key (
vyg_…), or Settings → Data API Keys for a conversations and providers key (vyg_ba_…). -
Create a key and choose its permissions (scopes). For this guide, a VYG API key with
customers:readis enough. -
Copy the key. It is shown once. Put it in your secret manager.
Keys can also be created over the API with POST /v1/keys; see API keys.
Store the key in an environment variable so it never lands in source control:
export VYG_API_KEY="vyg_your_key_here"2. Make your first request
Send the key as a bearer token. This request returns your top five customers by total spend:
curl -s "https://api.vyg.app/v1/customers?sort=total_spend&direction=desc&limit=5" \
-H "Authorization: Bearer $VYG_API_KEY"A successful response is a page of customers with a cursor:
{
"data": [
{
"id": "8f2b0c1e-5d7a-4b7e-9a51-2c6f1e0d3a44",
"email": "jane@example.com",
"phone": "+15551234567",
"orders_count": 12,
"total_spend": 1840.5,
"last_order_at": "2026-06-20T14:30:00.000Z"
}
],
"next_cursor": null
}From here:
- Filter with
min_ordersormin_spend. The parameters are in the Customers reference. - Page through results by passing
next_cursorback ascursorwhile it is notnull. - Fetch one customer, with their identities, with
GET /v1/customers/{id}. A single record is returned as a bare object, not wrapped indata.
3. If something goes wrong
| Status | error.code | What to check |
|---|---|---|
401 | unauthorized | The Authorization header is missing, or the key is wrong, revoked or expired. |
403 | insufficient_scope | The key needs additional permissions, or customer data features are unavailable. |
404 | not_found | The record could not be found. |
See Errors for the full list.
Next steps
- Authentication: API keys compared with sign-in tokens.
- Scopes: which scope each route and tool needs.
- Build your first app: a small customer dashboard.
- REST API reference: every route.