API pentru cont2026-11
Endpointuri webhook
URL-urile la care trimitem evenimente prin POST. Evenimentele, conținutul lor, semnarea și reîncercările sunt la Webhookuri.
Endpointuri
- POST/v1/webhook_endpointsCreează un endpoint
- GET/v1/webhook_endpointsListează endpointurile
- GET/v1/webhook_endpoints/{id}Preia un endpoint
- PATCH/v1/webhook_endpoints/{id}În curândActualizează un endpoint
- DELETE/v1/webhook_endpoints/{id}Șterge un endpoint
- POST/v1/webhook_endpoints/{id}/rotate_secretÎn curândRotește secretul
- POST/v1/webhook_endpoints/{id}/testTrimite un eveniment de test
- GET/v1/webhook_endpoints/{id}/deliveriesÎn curândListează livrările
- POST/v1/webhook_endpoints/{id}/deliveries/{delivery}/retryÎn curândTrimite din nou o livrare
Obiectul Webhook endpoint
idstring- Începe cu we_.
urlstring- Un URL https de-al tău care răspunde 2xx.
descriptionstring|null- Pentru tine.
events[]array- Tipurile de evenimente de trimis, sau
*pentru toate, inclusiv cele adăugate ulterior: order.created, order.paid, order.bought, order.held, order.cancelled, order.shipped, product.cost_changed, product.repriced, product.out_of_stock, product.paused, product.resumed, product.removed. statusstring- activat sau dezactivat (de tine sau de noi, după cinci zile în care toate livrările au eșuat; îți trimitem e-mail).
api_versionstring- Versiunea în care sunt scrise conținuturile evenimentelor. Deocamdată există una, 2026-11.
secretstring- Secretul de semnare. Doar în răspunsurile la create și rotate.
webhook_endpoint
{ "id": "we_3d8s", "url": "https://acme-goods.com/hooks/ninjabuy", "description": "Order sync", "events": ["order.shipped", "product.out_of_stock", "product.paused"], "status": "enabled", "api_version": "2026-11", "created_at": "2026-11-01T08:00:00Z"}Creează un endpoint
POST/v1/webhook_endpoints
Răspunde o singură dată cu secretul de semnare: păstrează-l acum. Până la 16 endpointuri per cont.
Domeniuwebhooks:write
Corp
urlstringobligatoriu- Doar https.
events[]arrayobligatoriu- Tipuri de evenimente sau ["*"].
descriptionstring- Opțional.
Erori
| Stare | Tip | Când |
|---|---|---|
| 400 | bad-body | URL-ul nu este https sau un tip de eveniment este necunoscut. |
| 409 | invalid-state | Contul are deja 16 endpointuri. |
curl -X POST "https://www.ninjabuy.com/api/v1/webhook_endpoints" \ -H "Authorization: Bearer " \ -H "NinjaBuy-Version: 2026-11" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "url": "https://acme-goods.com/hooks/ninjabuy", "events": ["order.shipped", "product.out_of_stock", "product.paused"], "description": "Order sync" }'Response · 201
HTTP/2 201 Created{ "id": "we_3d8s", "url": "https://acme-goods.com/hooks/ninjabuy", "description": "Order sync", "events": ["order.shipped", "product.out_of_stock", "product.paused"], "status": "enabled", "api_version": "2026-11", "created_at": "2026-11-01T08:00:00Z", "secret": "whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw"}Listează endpointurile
GET/v1/webhook_endpoints
Fiecare endpoint din cont, fără secrete.
Domeniuwebhooks:write
curl "https://www.ninjabuy.com/api/v1/webhook_endpoints" \ -H "Authorization: Bearer " \ -H "NinjaBuy-Version: 2026-11"Response · 200
HTTP/2 200 OK{ "data": [ { "id": "we_3d8s", "url": "https://acme-goods.com/hooks/ninjabuy", "description": "Order sync", "events": [ "order.shipped", "product.out_of_stock", "product.paused" ], "status": "enabled", "api_version": "2026-11", "created_at": "2026-11-01T08:00:00Z" } ], "has_more": false, "cursor": null}Preia un endpoint
GET/v1/webhook_endpoints/{id}
Un endpoint, fără secretul lui.
Domeniuwebhooks:write
Parametri de cale
idstringobligatoriu- Id-ul endpointului.
Erori
| Stare | Tip | Când |
|---|---|---|
| 404 | not-found | Niciun astfel de endpoint în acest cont. |
curl "https://www.ninjabuy.com/api/v1/webhook_endpoints/we_3d8s" \ -H "Authorization: Bearer " \ -H "NinjaBuy-Version: 2026-11"Response · 200
HTTP/2 200 OK{ "id": "we_3d8s", "url": "https://acme-goods.com/hooks/ninjabuy", "description": "Order sync", "events": ["order.shipped", "product.out_of_stock", "product.paused"], "status": "enabled", "api_version": "2026-11", "created_at": "2026-11-01T08:00:00Z"}Actualizează un endpoint
PATCH/v1/webhook_endpoints/{id}În curând
Schimbă-i URL-ul sau evenimentele sau dezactivează-l și activează-l. Activarea trimite ce a pierdut în ultimele 3 zile.
Domeniuwebhooks:write
Parametri de cale
idstringobligatoriu- Id-ul endpointului.
Corp
urlstring- Doar https.
events[]array- Tipuri de evenimente sau ["*"].
descriptionstring- Opțional.
statusstring- Opțional. enabled sau disabled.
Erori
| Stare | Tip | Când |
|---|---|---|
| 404 | not-found | Niciun astfel de endpoint în acest cont. |
curl -X PATCH "https://www.ninjabuy.com/api/v1/webhook_endpoints/we_3d8s" \ -H "Authorization: Bearer " \ -H "NinjaBuy-Version: 2026-11" \ -H "Content-Type: application/json" \ -d '{ "events": ["*"] }'Response · 200
HTTP/2 200 OK{ "id": "we_3d8s", "url": "https://acme-goods.com/hooks/ninjabuy", "description": "Order sync", "events": ["*"], "status": "enabled", "api_version": "2026-11", "created_at": "2026-11-01T08:00:00Z"}Șterge un endpoint
DELETE/v1/webhook_endpoints/{id}
Oprește imediat orice livrare către el, inclusiv reîncercările.
Domeniuwebhooks:write
Parametri de cale
idstringobligatoriu- Id-ul endpointului.
Erori
| Stare | Tip | Când |
|---|---|---|
| 404 | not-found | Niciun astfel de endpoint în acest cont. |
curl -X DELETE "https://www.ninjabuy.com/api/v1/webhook_endpoints/we_3d8s" \ -H "Authorization: Bearer " \ -H "NinjaBuy-Version: 2026-11"Response · 200
HTTP/2 200 OK{ "id": "we_3d8s", "deleted": true }Rotește secretul
POST/v1/webhook_endpoints/{id}/rotate_secretÎn curând
Răspunde cu un secret nou. Timp de 24 de ore semnăm cu ambele, deci antetul webhook-signature poartă două semnături și oricare se verifică: pune în producție secretul nou, apoi lasă-l pe cel vechi să expire.
Domeniuwebhooks:write
Parametri de cale
idstringobligatoriu- Id-ul endpointului.
Erori
| Stare | Tip | Când |
|---|---|---|
| 404 | not-found | Niciun astfel de endpoint în acest cont. |
curl -X POST "https://www.ninjabuy.com/api/v1/webhook_endpoints/we_3d8s/rotate_secret" \ -H "Authorization: Bearer " \ -H "NinjaBuy-Version: 2026-11" \ -H "Idempotency-Key: $(uuidgen)"Response · 200
HTTP/2 200 OK{ "id": "we_3d8s", "secret": "whsec_C2FVsBQIhrscChlQIMV+b5sSYspob7oD", "previous_expires_at": "2026-11-05T09:30:00Z"}Trimite un eveniment de test
POST/v1/webhook_endpoints/{id}/test
Pune în coadă un eșantion dintr-un tip de eveniment, semnat ca oricare altul, cu test: true. Receptorul confirmă livrarea când ajunge.
Domeniuwebhooks:write
Parametri de cale
idstringobligatoriu- Id-ul endpointului.
Corp
typestringobligatoriu- Un tip de eveniment.
Erori
| Stare | Tip | Când |
|---|---|---|
| 404 | not-found | Niciun astfel de endpoint în acest cont. |
curl -X POST "https://www.ninjabuy.com/api/v1/webhook_endpoints/we_3d8s/test" \ -H "Authorization: Bearer " \ -H "NinjaBuy-Version: 2026-11" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "type": "order.shipped" }'Response · 202
HTTP/2 202 Accepted{ "delivery": "dlv_0k2p", "status": "pending" }Listează livrările
GET/v1/webhook_endpoints/{id}/deliveriesÎn curând
Fiecare încercare din ultimele 30 de zile, cele mai noi primele: ce am trimis, cum ai răspuns și când reîncercăm.
Domeniuwebhooks:write
Parametri de cale
idstringobligatoriu- Id-ul endpointului.
Parametri de interogare
statusstring- Opțional. succeeded, retrying sau failed.
eventstring- Opțional. Un id de eveniment.
limit, cursor- Pagination
Erori
| Stare | Tip | Când |
|---|---|---|
| 404 | not-found | Niciun astfel de endpoint în acest cont. |
curl "https://www.ninjabuy.com/api/v1/webhook_endpoints/we_3d8s/deliveries?status=retrying" \ -H "Authorization: Bearer " \ -H "NinjaBuy-Version: 2026-11"Response · 200
HTTP/2 200 OK{ "data": [ { "id": "dlv_0k3a", "event": "evt_4m2x", "type": "order.shipped", "status": "retrying", "attempts": 3, "last_response_status": 502, "next_attempt_at": "2026-11-03T08:35:00Z" } ], "has_more": false, "cursor": null}Trimite din nou o livrare
POST/v1/webhook_endpoints/{id}/deliveries/{delivery}/retryÎn curând
Trimite acum evenimentul, cu același webhook-id, indiferent de starea lui. Reîncercările deja programate continuă.
Domeniuwebhooks:write
Parametri de cale
idstringobligatoriu- Id-ul endpointului.
deliverystringobligatoriu- Un ID de livrare.
Erori
| Stare | Tip | Când |
|---|---|---|
| 404 | not-found | Niciun astfel de endpoint în acest cont. |
curl -X POST "https://www.ninjabuy.com/api/v1/webhook_endpoints/we_3d8s/deliveries/dlv_0k3a/retry" \ -H "Authorization: Bearer " \ -H "NinjaBuy-Version: 2026-11" \ -H "Idempotency-Key: $(uuidgen)"Response · 202
HTTP/2 202 Accepted{ "delivery": "dlv_0k3a", "status": "retrying", "next_attempt_at": "2026-11-03T08:01:10Z"}