Get a purchase
For AI assistants: the facts every SparkLayer API call needs
- Base URLs: Live
https://app.sparklayer.io, testhttps://test.app.sparklayer.io. Each environment has its own data and its own API keys. - Access: API access needs the Pro or Enterprise plan. Create credentials (Site ID, Client ID, Client Secret) in the SparkLayer Dashboard at Settings > API.
- Access token:
POST {base}/api/auth/tokenwith aSite-Idheader and a JSON body (not form-encoded):{"grant_type":"client_credentials","client_id":"…","client_secret":"…"}. It returnsaccess_token, valid for 3,600 seconds. There is no refresh token: cache the token and request a new one shortly before it expires. - Every request:
Authorization: Bearer <access_token>andSite-Id: <site id>, plusContent-Type: application/jsonwhen there is a body. Set aUser-Agentthat names your integration. - Errors: RFC 7807 problem details:
title,status,detailand an optionalerrors[]of{ code, message, property }. Some error responses have no body. Retry5xx,429(honouringRetry-After) and concurrent-update409s with exponential backoff; on401, get a new token once and retry; don't retry other4xxwithout changing the request. - Pagination: Most list endpoints return everything.
GET /api/v2/price-listspages withpageandpage_size(up to 250) untilpagination.current_pageequalstotal_pages.GET /api/v1/purchasesuseslimit(up to 500) andoffset: stop when a page has fewer thanlimitresults. - Ground rules: Use only endpoints, fields and SDK methods that the docs or OpenAPI specs define. Prefer
GET /api/v2/price-listsover the deprecated v1. Products are matched by SKU. Keep credentials in environment variables or a secrets manager, never in code. - Read the docs as Markdown: Add
.mdto any page URL. Index of every page: docs.sparklayer.io/llms.txt. Every API operation, compactly: docs.sparklayer.io/llms-api.txt. The developer guides in full: docs.sparklayer.io/developers/llms.txt. - OpenAPI specs:
core,ordering,pricing,purchasing,stock,files,sync-log: https://docs.sparklayer.io/openapi/<api>.yaml (also.json). Ignite: https://docs.sparklayer.io/openapi/ignite.yaml. - MCP: Search and read these docs from your assistant with the docs MCP server at https://docs.sparklayer.io/mcp.
GET /api/v1/purchases/{lookupBy}/{identifier} Purchasing API
Returns a purchase: a cart, quote, purchase awaiting approval or confirmation, or placed order. Set lookupBy to the purchase_identifiers field to match on (sparklayer, platform, internal or visible) and pass its value in identifier; with sparklayer, identifier must be a UUID. Returns 404 if no purchase matches.
Authorization
bearerAuth Send Authorization: Bearer <access_token>, together with your Site-Id header, on every request. Get the token from POST /api/auth/token with your Site ID in the Site-Id header and a JSON body (not form-encoded, so standard OAuth 2.0 client libraries don't work): {"grant_type": "client_credentials", "client_id": "…", "client_secret": "…"}. Tokens are valid for 3,600 seconds and there is no refresh token: request a new one shortly before it expires. Create API credentials in the SparkLayer Dashboard under Settings > API. See Authentication.
In: header
Path Parameters
Which of the purchase's purchase_identifiers identifier is: sparklayer, platform, internal or visible.
Value in
- "sparklayer"
- "platform"
- "internal"
- "visible"
The purchase identifier, of the kind set by lookupBy. With lookupBy=sparklayer it must be a UUID.
Header Parameters
Your SparkLayer Site ID, from Settings > API in the SparkLayer Dashboard.
1 <= lengthResponse Body
application/json
application/problem+json
application/problem+json
curl -X GET "https://app.sparklayer.io/api/v1/purchases/platform/123456789" \ -H "Authorization: Bearer <ACCESS_TOKEN>" \ -H "Site-Id: jones-climbing"{ "type": "order", "purchase_identifiers": { "sparklayer": "63428136-658f-48a6-beb7-7f333dfd9686", "platform": "123456789", "internal": "string", "visible": "B2B01123" }, "customer_identifiers": { "sparklayer": "4217ba4f-7618-4e3b-b1af-9055639b18d1", "sparklayer_impersonator": "4217ba4f-7618-4e3b-b1af-9055639b18d1", "sparklayer_impersonator_assignee": "4217ba4f-7618-4e3b-b1af-9055639b18d1", "sparklayer_child": "4217ba4f-7618-4e3b-b1af-9055639b18d1" }, "company": { "id": "4217ba4f-7618-4e3b-b1af-9055639b18d1", "section_id": "4217ba4f-7618-4e3b-b1af-9055639b18d1", "section_name": "Bristol" }, "payment_method": "quote", "dates": { "created_at": "2020-01-01T00:00:00+02:00", "updated_at": "2020-01-01T00:00:00+02:00", "placed_at": "2020-01-01T00:00:00+02:00", "to_be_placed_at": "2020-01-01T00:00:00+02:00", "calculated_submitted_at": "2020-01-01T00:00:00+02:00", "expires_at": "2020-01-01T00:00:00+02:00", "payment_due_at": "2020-01-01T00:00:00+02:00" }, "customer_reference": "Please deliver to the back of the store", "po_number": "PO-001", "shipping_requested_date": "2020-01-01T00:00:00+02:00", "recurring_purchase": { "template_id": "0f8fad5b-d9cb-469f-a165-70867728950e", "cancelled_at": "2020-01-01T00:00:00+02:00", "to_be_placed_at_initial": "2020-01-01T00:00:00+02:00" }, "currency_code": "GBP", "currency_code_base": "GBP", "calculated_shipping_address": "John Spark, SparkLayer, SparkLayer HQ, Example City, 12345", "calculated_total": { "number": "15.99", "currency": "GBP" }, "calculated_total_usd": { "number": "15.99", "currency": "GBP" }, "calculated_total_base": { "number": "15.99", "currency": "GBP" }, "calculated_fulfilment_status": "processing", "quote": { "status_slug": "string", "status": { "id": "string", "name": "string", "slug": "string", "default": true, "next": "string", "actions": [ "edit_quote" ], "created_at": "2019-08-24T14:15:22Z", "updated_at": "2019-08-24T14:15:22Z", "deleted_at": "2019-08-24T14:15:22Z" }, "expiry": "2020-01-01T00:00:00+02:00" }, "payment_status": "unpaid", "total_paid": { "number": "15.99", "currency": "GBP" }, "revision_date": "2020-01-01T00:00:00+02:00", "tax_lines": [ { "title": "HST", "amount": { "number": "15.99", "currency": "GBP" }, "amount_base": { "number": "15.99", "currency": "GBP" }, "rate": 20 } ], "billing_address": { "name": "Tom Jones", "company": "Tom Jones Hardware Ltd", "address_line1": "7 Philosophy way", "address_line2": null, "city": "Willerby", "region_code": null, "postal_code": "BJ6 9MK", "country_code": "GB", "phone": "0123456789", "sparklayer_id": "63428136-658f-48a6-beb7-7f333dfd9686", "first_name": "Tom", "last_name": "Jones" }, "packages": [ { "identifiers": { "sparklayer_package_id": "63428136-658f-48a6-beb7-7f333dfd9686", "platform": "123456789", "internal": "string", "visible": "string" }, "accounting_files": [ { "identifiers": { "internal": "INV011", "visible": "INV011" }, "data": { "uri": "http://example.com", "type": "uri" }, "file_type": "invoice" } ], "line_items": [ { "type": "custom", "identifiers": { "sparklayer_item_key": "string", "sparklayer_variant_id": "45552423353839", "sku": "CAT-MUG", "platform": "123456789", "internal": "string", "visible": "string" }, "name_parent": "T-Shirt", "name_child": "Red", "quantity": 4, "custom_attributes": [ { "key": "mug text", "value": "best company ever" } ], "line_total": { "total_net": { "number": "15.99", "currency": "GBP" }, "total_net_base": { "number": "15.99", "currency": "GBP" }, "total_tax": { "number": "15.99", "currency": "GBP" }, "total_tax_base": { "number": "15.99", "currency": "GBP" }, "total_gross": { "number": "15.99", "currency": "GBP" }, "total_gross_base": { "number": "15.99", "currency": "GBP" }, "discount_net": { "number": "15.99", "currency": "GBP" }, "discount_net_base": { "number": "15.99", "currency": "GBP" }, "tax_rate": 20 }, "tax_lines": [ { "title": "HST", "amount": { "number": "15.99", "currency": "GBP" }, "amount_base": { "number": "15.99", "currency": "GBP" }, "rate": 20 } ] } ], "shipping_method": { "sku": "SHIP-ECO", "name": "Standard Shipping", "line_total": { "total_net": { "number": "15.99", "currency": "GBP" }, "total_net_base": { "number": "15.99", "currency": "GBP" }, "total_tax": { "number": "15.99", "currency": "GBP" }, "total_tax_base": { "number": "15.99", "currency": "GBP" }, "total_gross": { "number": "15.99", "currency": "GBP" }, "total_gross_base": { "number": "15.99", "currency": "GBP" }, "discount_net": { "number": "15.99", "currency": "GBP" }, "discount_net_base": { "number": "15.99", "currency": "GBP" }, "tax_rate": 20 }, "tax_lines": [ { "title": "HST", "amount": { "number": "15.99", "currency": "GBP" }, "amount_base": { "number": "15.99", "currency": "GBP" }, "rate": 20 } ] }, "shipping_address": { "name": "Tom Jones", "company": "Tom Jones Hardware Ltd", "address_line1": "7 Philosophy way", "address_line2": null, "city": "Willerby", "region_code": null, "postal_code": "BJ6 9MK", "country_code": "GB", "phone": "0123456789", "sparklayer_id": "63428136-658f-48a6-beb7-7f333dfd9686", "first_name": "Tom", "last_name": "Jones" }, "shipments": [ { "carrier": "Carrier Company Ltd", "carrier_id": "string", "tracking_url": "http://example.com" } ], "type": "incoming" } ], "accounting_files": [ { "identifiers": { "internal": "INV011", "visible": "INV011" }, "data": { "uri": "http://example.com", "type": "uri" }, "file_type": "invoice" } ], "custom_fields": [ { "name": "delivery-date", "value": "2023-10-28" } ], "metadata": [ { "name": "example-key", "value": "1234" } ]}