Integrations
Custom commerce API v1
Overview #
Push customers and orders from your store. TGCPilot never requests your store URL. Base path: /integrations/custom-commerce/v1.
Auth #
Send X-TGC-Key-Id, X-TGC-Timestamp (Unix seconds), X-TGC-Signature. Sign timestamp + "." + exact raw request bytes with HMAC-SHA256; prefix lowercase hex with v1=. For GET /status sign an empty body. Keep secrets on your server. Use the current timestamp; the worked timestamp below is illustrative. Rotation accepts the previous key during the configured overlap; revoke replaces it immediately.
X-TGC-Key-Id: cck_01EXAMPLE
Secret: example-secret-do-not-use
X-TGC-Timestamp: 1793178000
Body: {"store_id":"kw-main","records":[]}
X-TGC-Signature: v1=3c8248ee07907dcfb3f2b54bd59dba668bafeda3bc0846fcb28536e635a1080d
Records #
Required envelope: store_id, records[]. Every record requires type, id (1–64 ASCII letters/digits or . _ : -), updated_at (RFC 3339 with offset); version is an optional nonnegative integer. customer.upsert requires data.created_at; optional email, phone, first_name, last_name, locale, marketing_consent (granted/denied/unknown), addresses[]. Consent is informational and never grants WhatsApp consent. Local Kuwaiti phones and Arabic digits are accepted. order.upsert requires data.number, currency, status, payment_status, fulfillment_status, subtotal, discount_total, shipping_total, tax_total, total, created_at, items[]. Optional customer_id, customer_snapshot (phone/email/name), refunded_total, test, normalized_status, normalized_payment_status, normalized_fulfillment_status, fulfillments[]. Items require id, title, quantity, unit_price, total; optional sku, product_id, variant_id. Fulfillments require id, status, updated_at; optional normalized_status, tracking_number, tracking_url. Declare optional capabilities through a passing check.
Money #
Use digit strings in currency minor units, at most 18 digits. KWD has three decimals: "12500" = 12.500 KWD. Never send decimals or floats. Currency must be supported. Item totals must equal quantity × unit_price; subtotal equals item totals; total = subtotal − discount_total + shipping_total + tax_total. Tolerance is zero.
Statuses #
Keep merchant statuses and optionally supply these normalized values in the corresponding normalized fields.
normalized_status- open, completed, cancelled, unknown
normalized_payment_status- pending, authorized, paid, partially_paid, partially_refunded, refunded, voided, failed, unknown
normalized_fulfillment_status- unfulfilled, partially_fulfilled, fulfilled, in_transit, delivered, returned, not_required, not_provided, unknown
Ordering #
Use increasing version, otherwise updated_at. Never mix marker strategies for one record. Resends are idempotent; older markers are superseded. Send a newer customer update during the check to prove ordering.
Backfill #
After activation POST /records with history from the fixed history_from returned by GET /status, then POST /backfill/complete with {"store_id":"kw-main"}. Completion is idempotent. Keep streaming live changes during import. An overdue notice does not stop ingestion.
Deletions #
customer.delete and order.delete require the common record fields. customer.erase optionally takes data.phone/email and hashes them at receipt. store.erase uses the store id and blocks subsequent records immediately. Erasure requests are applied at receipt; deleted records retain ordering tombstones.
Outcomes #
HTTP 200 returns one result per input, in order: accepted (durable), duplicate (already accepted), superseded (newer accepted), rejected (fix rule/field then resend). Optional warning: {rule, field} means undeclared capability data was ignored. Request refusals store nothing. Retry 429/503 using Retry-After; split 413 batches; fix 401/422; activate after 403; stop after 410.
missing_field- Include the required field.
invalid_type- Use the documented JSON type.
invalid_identifier- Use a stable identifier of up to 64 allowed characters.
timestamp_without_zone- Include a time zone in the timestamp.
timestamp_in_future- Use a timestamp within the allowed clock tolerance.
before_history_window- Send records inside the historical import window.
invalid_money- Send money as a string of minor-unit digits.
unknown_currency- Use a supported currency code.
money_mismatch- Make the item and order totals agree.
too_many_items- Reduce the number of order items.
record_too_large- Reduce this record to the published size limit.
undeclared_capability- Declare this capability through a passing integration check.
unknown_type- Use a supported record type.
duplicate_in_batch_conflict- Send identical content for identical identifiers and change markers.
identifier_reuse- Do not reuse a deleted record identifier.
store_erased- This store has been erased and cannot accept more records.
401 unauthenticated / store_mismatch 403 not_active 410 disconnected / store_erased 413 body_too_large / batch_too_many_records 422 malformed_request 429 rate_limited 503 paused / backlog_full / unavailable 409 no_open_check / check_full / not_importing
Limits #
Configured limits (bytes and time units are shown in the key).
requests_per_minute |
120 |
ip_per_minute |
3000 |
records_per_batch |
100 |
record_bytes |
65536 |
body_bytes |
2097152 |
backlog |
5000 |
timestamp_tolerance_seconds |
300 |
future_skew_seconds |
300 |
history_days |
90 |
backfill_overdue_days |
7 |
check_window_minutes |
30 |
check_valid_hours |
24 |
rotation_overlap_hours |
24 |
paused_retry_after_seconds |
300 |
authority_retry_after_seconds |
15 |
silence_hours_default |
24 |
rejections_retention_days |
30 |
checks_kept_per_connection |
20 |
check_max_results |
200 |
check_max_records |
500 |
Check #
Start a check in connection settings, send signed samples to POST /check/records, then evaluate. No commerce projections are written. Every mandatory requirement must pass; optional capabilities are discovered only on a pass. Failed security checks pause an active connection.
auth.signature
Signed requests
auth.store_identity
Store identity
customers.present
Customer sample
orders.present
Order sample
records.required_fields
Required fields
records.identifiers
Stable identifiers
records.change_markers
Change timestamps
money.minor_units
Amounts in minor units
statuses.vocabulary
Normalized statuses
ordering.newer_wins
Newer changes win
batching.limits
Batch and record limits
fulfillments.shape
Fulfillments
product_refs.shape
Product references
deletions.shape
Deletion and erasure samples
Samples #
Send these four files in order during the check. Example dates are fixed to 2026-10-28; refresh dates within your current check window when using this guide later.
{
"store_id": "kw-main",
"records": [
{
"type": "customer.upsert",
"id": "C-1001",
"updated_at": "2026-10-27T10:00:00+03:00",
"version": 1,
"data": {
"first_name": "Sara",
"last_name": "Al-Sabah",
"phone": "+96550001234",
"email": "sara@example.kw",
"created_at": "2026-10-10T10:00:00+03:00"
}
},
{
"type": "customer.upsert",
"id": "C-1002",
"updated_at": "2026-10-27T10:00:00+03:00",
"version": 1,
"data": {
"first_name": "نورة",
"last_name": "العتيبي",
"phone": "٥٥٠٠١٢٣٥",
"marketing_consent": "granted",
"created_at": "2026-10-11T10:00:00+03:00",
"addresses": [
{
"address1": "قطعة ٥، شارع ١٢",
"city": "الكويت",
"country": "KW"
}
]
}
}
]
}
{
"store_id": "kw-main",
"records": [
{
"type": "order.upsert",
"id": "O-5001",
"updated_at": "2026-10-27T10:00:00+03:00",
"data": {
"number": "5001",
"customer_id": "C-1001",
"currency": "KWD",
"status": "completed",
"normalized_status": "open",
"payment_status": "paid",
"normalized_payment_status": "paid",
"fulfillment_status": "delivered",
"normalized_fulfillment_status": "fulfilled",
"subtotal": "25000",
"discount_total": "1000",
"shipping_total": "500",
"tax_total": "0",
"total": "24500",
"refunded_total": "0",
"created_at": "2026-10-20T10:00:00+03:00",
"items": [
{
"id": "I-1",
"title": "Dates gift box",
"quantity": 1,
"unit_price": "12500",
"total": "12500",
"product_id": "P-1",
"variant_id": "V-1"
},
{
"id": "I-2",
"title": "Coffee gift box",
"quantity": 1,
"unit_price": "12500",
"total": "12500"
}
],
"fulfillments": [
{
"id": "F-1",
"status": "fulfilled",
"tracking_number": "KW123456",
"updated_at": "2026-10-27T10:00:00+03:00"
}
]
}
},
{
"type": "order.upsert",
"id": "O-5002",
"updated_at": "2026-10-27T10:00:00+03:00",
"data": {
"number": "5002",
"currency": "KWD",
"status": "تم التأكيد",
"payment_status": "عند الاستلام",
"fulfillment_status": "قيد التجهيز",
"subtotal": "12500",
"discount_total": "0",
"shipping_total": "0",
"tax_total": "0",
"total": "12500",
"created_at": "2026-10-21T10:00:00+03:00",
"test": true,
"customer_snapshot": {
"name": "خالد الهاجري",
"phone": "+96550001236"
},
"items": [
{
"id": "I-3",
"title": "علبة تمر",
"quantity": 1,
"unit_price": "12500",
"total": "12500"
}
]
}
}
]
}
{
"store_id": "kw-main",
"records": [
{
"type": "customer.upsert",
"id": "C-1001",
"updated_at": "2026-10-28T10:00:00+03:00",
"version": 2,
"data": {
"first_name": "Sara",
"last_name": "Al-Hamad",
"phone": "+96550001234",
"email": "sara@example.kw",
"created_at": "2026-10-10T10:00:00+03:00"
}
}
]
}
{
"store_id": "kw-main",
"records": [
{
"type": "order.delete",
"id": "O-4999",
"updated_at": "2026-10-27T10:00:00+03:00"
},
{
"type": "customer.erase",
"id": "C-0007",
"updated_at": "2026-10-27T10:00:00+03:00",
"data": {
"phone": "+96550000000"
}
}
]
}
Walkthrough #
1. Create connection → 2. Store credentials securely → 3. Start check → 4. Send samples → 5. Evaluate → 6. Activate → 7. Backfill → 8. Complete → 9. Stream live changes → 10. Rotate credentials.
Changelog #
v1 — 2026-10-28 — first release. After beta only additive optional fields; breaking changes use v2 with a published deprecation date.