{"openapi":"3.0.3","info":{"title":"Tescommerce Merchant API","version":"1.0.0","description":"Public Admin API authenticated with a store API key (`Authorization: Bearer ugc_…` or `X-Api-Key`). Create keys in the admin under Growth → Webhooks & API. A key is full, read, products, or orders. A test key (prefix ugc_test_) reads the live store but does not save writes or call Stripe. POST writes accept Idempotency-Key and replay the first response for 24 hours. Product and order lists accept updatedSince and createdSince (ISO 8601 UTC). Amounts are minor units. Lists take limit (1–100) and cursor. Timestamps are ISO 8601 UTC. Guide: https://tescommerce.com/developers. Outbound webhooks (Growth → Webhooks & API, also usable from Zapier and Make Catch Hook) are described under x-webhooks: order.paid, order.fulfilled and order.tracking_updated are delivered as POST JSON wrapped in an envelope (id, event, createdAt, attempt, data) and signed with X-UGCLab-Signature (sha256= plus HMAC-SHA256 of the raw body). Test sends from the admin use test: true and orderId test_order."},"x-webhooks":{"order.paid":{"post":{"summary":"order.paid","description":"Sent when an order is paid. Payload fields: orderId, orderNumber, totalAmount (minor units), currency.","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"event":{"type":"string","example":"order.paid"},"createdAt":{"type":"string","format":"date-time"},"attempt":{"type":"integer"},"data":{"type":"object","properties":{"orderId":{"type":"string"},"orderNumber":{"type":"string"},"totalAmount":{"type":"integer","description":"Minor units (cents)"},"currency":{"type":"string","example":"USD"}}}}}}}},"responses":{"200":{"description":"Return any 2xx to acknowledge"}}}},"order.fulfilled":{"post":{"summary":"order.fulfilled","description":"Sent when an order is marked fulfilled. Payload fields: orderId, orderNumber.","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"event":{"type":"string","example":"order.fulfilled"},"createdAt":{"type":"string","format":"date-time"},"attempt":{"type":"integer"},"data":{"type":"object","properties":{"orderId":{"type":"string"},"orderNumber":{"type":"string"}}}}}}}},"responses":{"200":{"description":"Return any 2xx to acknowledge"}}}},"order.tracking_updated":{"post":{"summary":"order.tracking_updated","description":"Sent when a carrier reports a new tracking checkpoint for an order. Payload fields: orderId, orderNumber, trackingNumber, status, checkpoint, location, occurredAt (ISO 8601 UTC), provider.","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"event":{"type":"string","example":"order.tracking_updated"},"createdAt":{"type":"string","format":"date-time"},"attempt":{"type":"integer"},"data":{"type":"object","properties":{"orderId":{"type":"string"},"orderNumber":{"type":"string"},"trackingNumber":{"type":"string"},"status":{"type":"string"},"checkpoint":{"type":"string","nullable":true},"location":{"type":"string","nullable":true},"occurredAt":{"type":"string","format":"date-time"},"provider":{"type":"string"}}}}}}}},"responses":{"200":{"description":"Return any 2xx to acknowledge"}}}}},"servers":[{"url":"https://ugclab-devs-api.vercel.app/api/v1"}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"ugc_","description":"Merchant API key starting with ugc_"},"ApiKeyHeader":{"type":"apiKey","in":"header","name":"X-Api-Key"}},"schemas":{"Error":{"type":"object","properties":{"error":{"type":"string"},"retryAfterSec":{"type":"integer"}}},"ProductSummary":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"slug":{"type":"string"},"status":{"type":"string"},"type":{"type":"string"},"priceAmount":{"type":"integer","description":"Minor units (cents)"},"compareAt":{"type":"integer","nullable":true},"inventory":{"type":"integer","nullable":true},"updatedAt":{"type":"string","format":"date-time"}}},"OrderSummary":{"type":"object","properties":{"id":{"type":"string"},"orderNumber":{"type":"string"},"invoiceNumber":{"type":"string","nullable":true},"status":{"type":"string"},"totalAmount":{"type":"integer"},"tipAmount":{"type":"integer","description":"Tip in minor units"},"storeCreditAmount":{"type":"integer","description":"Store credit applied, minor units"},"loyaltyDiscountAmount":{"type":"integer"},"customFields":{"type":"object","nullable":true,"additionalProperties":{"type":"string"},"description":"Answers to merchant-defined checkout fields"},"currency":{"type":"string"},"guestEmail":{"type":"string","nullable":true},"createdAt":{"type":"string","format":"date-time"},"customer":{"type":"object","nullable":true,"properties":{"email":{"type":"string"},"name":{"type":"string","nullable":true}}}}},"Page":{"type":"object","properties":{"nextCursor":{"type":"string","nullable":true}}}}},"security":[{"BearerAuth":[]},{"ApiKeyHeader":[]}],"paths":{"/":{"get":{"summary":"API info","security":[],"responses":{"200":{"description":"Service metadata"}}}},"/openapi.json":{"get":{"summary":"This OpenAPI document","security":[],"responses":{"200":{"description":"OpenAPI 3 JSON"}}}},"/products":{"get":{"summary":"List products","parameters":[{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":25}},{"name":"cursor","in":"query","schema":{"type":"string"}},{"name":"status","in":"query","schema":{"type":"string","enum":["DRAFT","ACTIVE","ARCHIVED"]}},{"name":"updatedSince","in":"query","schema":{"type":"string","format":"date-time"}},{"name":"createdSince","in":"query","schema":{"type":"string","format":"date-time"}}],"responses":{"200":{"description":"Product list","content":{"application/json":{"schema":{"type":"object","properties":{"products":{"type":"array","items":{"$ref":"#/components/schemas/ProductSummary"}},"currency":{"type":"string"},"nextCursor":{"type":"string","nullable":true}}}}}},"401":{"description":"Invalid API key"},"429":{"description":"Rate limited"}}},"post":{"summary":"Create a product","description":"priceAmount is minor units. status defaults to DRAFT. Digital files are uploaded in the admin. Optional Idempotency-Key header. A test key returns test: true and does not save the product.","parameters":[{"name":"Idempotency-Key","in":"header","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["title","priceAmount"],"properties":{"title":{"type":"string"},"slug":{"type":"string"},"description":{"type":"string"},"type":{"type":"string","enum":["PHYSICAL","DIGITAL","SERVICE"]},"status":{"type":"string","enum":["DRAFT","ACTIVE"]},"priceAmount":{"type":"integer"},"compareAt":{"type":"integer","nullable":true},"inventory":{"type":"integer","nullable":true},"sku":{"type":"string"},"barcode":{"type":"string"},"tags":{"type":"array","items":{"type":"string"}}}}}}},"responses":{"201":{"description":"Created"},"400":{"description":"Invalid body"},"409":{"description":"Slug already used"}}}},"/products/{id}":{"get":{"summary":"Get product","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Product with images and variants"},"404":{"description":"Not found"}}},"patch":{"summary":"Update a product","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object"}}}},"responses":{"200":{"description":"Updated product"},"404":{"description":"Not found"}}}},"/products/{id}/inventory":{"post":{"summary":"Set or adjust inventory","description":"Send inventory (absolute) or adjust (delta), not both. Optional variantId.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object"}}}},"responses":{"200":{"description":"New inventory count"},"400":{"description":"Invalid adjustment"}}}},"/orders":{"get":{"summary":"List orders","parameters":[{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":25}},{"name":"cursor","in":"query","schema":{"type":"string"}},{"name":"status","in":"query","schema":{"type":"string","enum":["DRAFT","PENDING","PAID","FULFILLED","CANCELLED","REFUNDED"]}},{"name":"updatedSince","in":"query","schema":{"type":"string","format":"date-time"}},{"name":"createdSince","in":"query","schema":{"type":"string","format":"date-time"}}],"responses":{"200":{"description":"Order list","content":{"application/json":{"schema":{"type":"object","properties":{"orders":{"type":"array","items":{"$ref":"#/components/schemas/OrderSummary"}},"nextCursor":{"type":"string","nullable":true}}}}}}}}},"/orders/{id}":{"get":{"summary":"Get order","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Order with line items"},"404":{"description":"Not found"}}}},"/orders/{id}/fulfill":{"post":{"summary":"Mark a paid order fulfilled","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"Idempotency-Key","in":"header","schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"trackingNumber":{"type":"string"},"notifyCustomer":{"type":"boolean"}}}}}},"responses":{"200":{"description":"Fulfilled order"},"400":{"description":"Order is not paid, or tracking is required"}}}},"/orders/{id}/refund":{"post":{"summary":"Refund a paid or fulfilled order","description":"Charges a Stripe refund when the order has a Stripe payment. Otherwise records the refund. amountCents is optional and defaults to the remaining total.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"Idempotency-Key","in":"header","schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"amountCents":{"type":"integer"},"reason":{"type":"string"},"toStoreCredit":{"type":"boolean"}}}}}},"responses":{"200":{"description":"Refund recorded"},"400":{"description":"Order cannot be refunded"}}}},"/customers":{"get":{"summary":"List customers","parameters":[{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":25}},{"name":"cursor","in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"Customers, without password hashes"}}}},"/customers/{id}":{"get":{"summary":"Get a customer","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Customer"},"404":{"description":"Not found"}}}},"/discounts":{"get":{"summary":"List discount codes","parameters":[{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":25}},{"name":"cursor","in":"query","schema":{"type":"string"}},{"name":"active","in":"query","schema":{"type":"boolean"}}],"responses":{"200":{"description":"Discount codes. PERCENT value is a percent; FIXED value is minor units."}}}},"/metafields":{"get":{"summary":"List metafields","parameters":[{"name":"ownerType","in":"query","required":true,"schema":{"type":"string","enum":["PRODUCT","VARIANT","CUSTOMER","ORDER","SHOP","METAOBJECT"]}},{"name":"ownerId","in":"query","schema":{"type":"string"}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":25}},{"name":"cursor","in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"Metafields"}}}}}}