← Tescommerce home

Tescommerce · Developers

Merchant API

Read and update one store with an API key: catalog, inventory, orders, refunds, customers, discounts, and metafields.

Quick start

  1. In the admin, open Growth → Webhooks & API and create a key. Copy the ugc_ secret. It is shown once.
  2. Call the API with that key.
    curl https://api.tescommerce.com/api/v1/products \
      -H "Authorization: Bearer ugc_…"
  3. The response is your products, one page at a time. nextCursor is null when the list is finished.

Authentication

Create the key in the admin under Growth → Webhooks & API. It is shown once and starts with ugc_.

The same key is accepted in the X-Api-Key header.

What a key can do

A key is full, read, products, or orders. full is the default and can do every call. read can only GET. products can read and change the catalog, including inventory. orders can read orders and mark them fulfilled or refunded. Customers, discounts, and metafields need read or full. A key that is not allowed answers 403.

Test key

Tick test mode when you create the key. The secret starts with ugc_test_. GET still returns the live store. POST and PATCH answer with test: true and do not save a product, change stock, mark an order fulfilled, or call Stripe. It is a dry run on your store, not a second store.

Money fields are minor units. 1999 is 19.99 in the store currency. A percent discount stores the percent in value, not cents.

curl https://api.tescommerce.com/api/v1/products \
  -H "Authorization: Bearer ugc_…"

curl https://api.tescommerce.com/api/v1/products \
  -H "X-Api-Key: ugc_…"
const res = await fetch("https://api.tescommerce.com/api/v1/products", {
  headers: { Authorization: "Bearer ugc_…" }
});
const body = await res.json();

Limits

120 requests per minute from one IP address, then 300 per minute for a valid key. 30 failed keys from one IP are blocked for 15 minutes. A 429 response includes Retry-After, in seconds.

HTTP/1.1 429 Too Many Requests
Retry-After: 12

{ "error": "Too many requests. Try again later.", "retryAfterSec": 12 }

Pages

Every list takes limit from 1 to 100 (default 25) and cursor. Send the previous nextCursor until it is null.

Pass updatedSince or createdSince as an ISO 8601 timestamp to read only rows changed or created after that instant. A value that is not a timestamp is 400.

Every timestamp in a JSON body is ISO 8601 in UTC, for example 2026-11-15T08:00:00.000Z.

Send Idempotency-Key on POST /products, POST /products/:id/inventory, POST /orders/:id/fulfill, and POST /orders/:id/refund. The same key and the same body replay the first response for 24 hours, including a test-key response. The same key with a different body is 409.

curl "https://api.tescommerce.com/api/v1/products?limit=50&updatedSince=2026-11-01T00:00:00.000Z" \
  -H "Authorization: Bearer ugc_…"
{
  "products": [{
    "id": "clproduct",
    "title": "Tee",
    "slug": "tee",
    "status": "ACTIVE",
    "type": "PHYSICAL",
    "priceAmount": 1999,
    "compareAt": null,
    "inventory": 12,
    "updatedAt": "2026-11-15T08:00:00.000Z"
  }],
  "currency": "USD",
  "nextCursor": null
}

Reference

OpenAPI: https://api.tescommerce.com/api/v1/openapi.json

GET /products

Active and draft products. Pass status=ARCHIVED to see archived rows. Soft-deleted products are omitted.

{
  "products": [{
    "id": "clproduct",
    "title": "Tee",
    "slug": "tee",
    "status": "ACTIVE",
    "type": "PHYSICAL",
    "priceAmount": 1999,
    "compareAt": null,
    "inventory": 12,
    "updatedAt": "2026-11-15T08:00:00.000Z"
  }],
  "currency": "USD",
  "nextCursor": null
}

POST /products

priceAmount is required. status defaults to DRAFT. The slug is taken from the title when you omit it.

curl https://api.tescommerce.com/api/v1/products \
  -H "Authorization: Bearer ugc_…" \
  -H "Content-Type: application/json" \
  -d '{"title":"Tee","priceAmount":1999,"inventory":12}'

{
  "product": {
    "id": "clproduct",
    "title": "Tee",
    "slug": "tee",
    "description": null,
    "status": "DRAFT",
    "type": "PHYSICAL",
    "priceAmount": 1999,
    "compareAt": null,
    "inventory": 12,
    "sku": null,
    "barcode": null,
    "tags": [],
    "currency": "USD",
    "updatedAt": "2026-11-15T08:00:00.000Z"
  }
}

GET /products/:id

Includes images (storageKey, fileName, alt, sortOrder) and variants (id, title, sku, priceAmount, inventory).

curl https://api.tescommerce.com/api/v1/products/clproduct \
  -H "Authorization: Bearer ugc_…"

PATCH /products/:id

Send only the fields that change. priceAmount and inventory are minor units and a count.

curl https://api.tescommerce.com/api/v1/products/clproduct \
  -X PATCH \
  -H "Authorization: Bearer ugc_…" \
  -H "Content-Type: application/json" \
  -d '{"status":"ACTIVE","priceAmount":2499}'

POST /products/:id/inventory

Send inventory or adjust, not both. Result below zero is rejected. variantId updates that variant.

curl https://api.tescommerce.com/api/v1/products/clproduct/inventory \
  -H "Authorization: Bearer ugc_…" \
  -H "Content-Type: application/json" \
  -d '{"adjust":-1}'

{ "productId": "clproduct", "variantId": null, "inventory": 11 }

GET /orders

Optional status: DRAFT, PENDING, PAID, FULFILLED, CANCELLED, REFUNDED.

{
  "orders": [{
    "id": "clorder",
    "orderNumber": "1001",
    "status": "PAID",
    "totalAmount": 1999,
    "currency": "USD",
    "guestEmail": "buyer@example.com",
    "createdAt": "2026-11-15T08:00:00.000Z",
    "customer": { "email": "buyer@example.com", "name": "Aya" }
  }],
  "nextCursor": null
}

GET /orders/:id

Line items include title, quantity, unitAmount, and totalAmount.

{
  "order": {
    "id": "clorder",
    "orderNumber": "1001",
    "status": "PAID",
    "currency": "USD",
    "totalAmount": 1999,
    "guestEmail": "buyer@example.com",
    "items": [{
      "id": "clline",
      "title": "Tee",
      "quantity": 1,
      "unitAmount": 1999,
      "totalAmount": 1999
    }],
    "customer": { "id": "clcustomer", "email": "buyer@example.com", "name": "Aya" }
  }
}

POST /orders/:id/fulfill

The order must be PAID. Buyer-protection orders need trackingNumber before the charge is captured.

curl https://api.tescommerce.com/api/v1/orders/clorder/fulfill \
  -H "Authorization: Bearer ugc_…" \
  -H "Content-Type: application/json" \
  -d '{"trackingNumber":"1Z999","notifyCustomer":true}'

POST /orders/:id/refund

Paid or fulfilled orders. Stripe is refunded when the order has a Stripe payment. amountCents defaults to the remainder.

curl https://api.tescommerce.com/api/v1/orders/clorder/refund \
  -H "Authorization: Bearer ugc_…" \
  -H "Content-Type: application/json" \
  -d '{"amountCents":500,"reason":"Short ship"}'

{
  "order": { "id": "clorder", "status": "PAID" },
  "stripeRefund": true,
  "partial": true,
  "refundAmountCents": 500
}

GET /customers

Password hashes and reset tokens are not included. Merged-away customers are omitted from the list.

{
  "customers": [{
    "id": "clcustomer",
    "email": "buyer@example.com",
    "name": "Aya",
    "country": "KG",
    "marketingOptOut": false,
    "loyaltyPoints": 0,
    "storeCreditCents": 0,
    "createdAt": "2026-11-15T08:00:00.000Z"
  }],
  "nextCursor": null
}

GET /discounts

PERCENT value is a percent. FIXED value is minor units. Optional active=true or active=false.

{
  "discounts": [{
    "id": "cldiscount",
    "code": "WELCOME10",
    "type": "PERCENT",
    "value": 10,
    "valueKind": "percent",
    "active": true,
    "usedCount": 3,
    "maxUses": 100
  }],
  "nextCursor": null
}

GET /metafields?ownerType=PRODUCT&ownerId=clproduct

ownerType is required: PRODUCT, VARIANT, CUSTOMER, ORDER, SHOP, or METAOBJECT. ownerId narrows to one record.

{
  "metafields": [{
    "id": "clmeta",
    "ownerType": "PRODUCT",
    "ownerId": "clproduct",
    "namespace": "custom",
    "key": "material",
    "type": "single_line_text",
    "value": "Cotton",
    "updatedAt": "2026-11-15T08:00:00.000Z"
  }],
  "nextCursor": null
}

Errors

401 { "error": "Missing or invalid API key" }
400 { "error": "priceAmount must be a whole number of minor units (cents)" }
400 { "error": "Invalid cursor" }
400 { "error": "Only a paid order can be marked fulfilled" }
404 { "error": "Not found" }
403 { "error": "This API key cannot do that" }
409 { "error": "Slug already used" }
409 { "error": "Idempotency key was already used with a different request" }
429 { "error": "Too many requests. Try again later.", "retryAfterSec": 12 }

Webhooks

Subscribe in Growth → Webhooks & API. The request times out after 8 seconds. Redirects are not followed. Failures retry after 1 minute, 5 minutes, 30 minutes, 2 hours, and 12 hours. A test delivery from the admin adds "test": true.

How to answer

Answer 2xx to accept the delivery. Any other status, a timeout, or a redirect is a failure and will be retried.

The signature has no timestamp, so you cannot reject an old delivery by age. Retries send the same event again and raise attempt. Store the delivery id (the JSON id, also the X-UGCLab-Delivery header) and ignore a repeat.

{
  "id": "cldelivery",
  "event": "order.paid",
  "createdAt": "2026-11-15T08:00:00.000Z",
  "attempt": 1,
  "data": {
    "orderId": "clorder",
    "orderNumber": "1001",
    "totalAmount": 1999,
    "currency": "USD"
  }
}

X-UGCLab-Event, X-UGCLab-Delivery, X-UGCLab-Signature: sha256=…

Event data

  • order.createdorderId, orderNumber, totalAmount, currency
  • order.paidorderId, orderNumber, totalAmount, currency
  • order.fulfilledorderId, orderNumber
  • product.createdproductId, title, slug
  • product.updatedproductId, title, slug. inventory when stock changes through this API
  • customer.createdcustomerId, email
  • subscription.updatedsubscriptionId, status
  • order.refundedorderId, orderNumber, refundAmountCents, currency, partial
  • order.cancelledorderId, orderNumber
  • order.tracking_updatedorderId, orderNumber, trackingNumber, status, checkpoint, location, occurredAt, provider

Check the signature

Compare the header with an HMAC-SHA256 of the raw body, using the endpoint secret. Parse JSON only after the check. Re-serializing the body changes the signature.

import { createHmac, timingSafeEqual } from "node:crypto";

export function verifyWebhook(rawBody, header, secret) {
  const expected = "sha256=" + createHmac("sha256", secret).update(rawBody).digest("hex");
  const a = Buffer.from(expected);
  const b = Buffer.from(header ?? "");
  return a.length === b.length && timingSafeEqual(a, b);
}
import hashlib, hmac

def verify_webhook(raw: bytes, header: str, secret: str) -> bool:
    expected = "sha256=" + hmac.new(secret.encode(), raw, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, header or "")
function verify_webhook(string $raw, string $header, string $secret): bool {
    $expected = "sha256=" . hash_hmac("sha256", $raw, $secret);
    return hash_equals($expected, $header);
}

Version

The public contract is v1. This version lists and updates products, sets inventory, lists orders, marks them fulfilled, refunds them, and reads customers, discounts, and metafields. Lists are cursor pages. Nine webhook events are included.

Changelog

v1 — 2026-11. First public contract: catalog and order reads and writes, cursor pages, customers, discounts, metafields, and the webhook events on this page.

Removing a field, changing a field’s type, or changing how a key is checked is a breaking change and needs a new version. Adding a field or an event is not.

Client

There is no official library. Call HTTPS yourself, or generate a client from the OpenAPI document.

Status and support

Platform status is on the status page. For a question about your store, use the email on your account or the contact page. /status · Contact