Support API and webhooks

Your developers can create support tickets from your company's own app, website or back office with a brand's secret key, and ASTRO CSM can tell your own systems when tickets are created, change status, get a reply or are solved. Both are set up per brand under Support, API and webhooks.

Make a key

  1. Open Support, then API and webhooks.
  2. Under New key, give the key a name you will recognise (such as "Customer portal"), choose the brand, and tick what it may do: create tickets and add customer messages, read tickets, or both.
  3. Select Create key. The key (it starts with sk_) is shown once: select Copy and hand it to your developer through a safe channel. ASTRO CSM keeps only a fingerprint of it, so nobody can show it again.

The key alone decides which brand the tickets belong to. Rotate gives the key a new secret and stops the old one at once; Revoke stops it for good. The list shows when each key was last used.

For your developer

  • Send the key in every request as Authorization: Bearer sk_..., to /api/public/support/v1 on your ASTRO CSM address.
  • POST /tickets creates a ticket (subject, body, type, priority, requester e-mail and name). A problem or a question needs the customer's e-mail. Send your own externalId and a retry of the same request answers the first ticket instead of making a second.
  • GET /tickets/{id} and GET /tickets?externalId=... read a ticket with its replies. Internal notes are never included.
  • POST /tickets/{id}/messages adds the customer's message. A solved ticket opens again; a closed ticket takes no more messages.
  • The full description is the OpenAPI document: select download the API description on the screen.
  • Each key may make a limited number of requests a minute; above that the answer is "too many requests" for a moment. Many wrong keys from one place are refused for a few minutes.

Add a webhook

  1. Under New webhook, enter the address of your system that should receive the events. It must start with https:// and be reachable on the internet.
  2. Choose the brand and the events, and select Add webhook.
  3. Copy the signing secret shown once and give it to your developer, who uses it to check that each event really comes from ASTRO CSM.

Each event is sent within about a minute, with the ticket and, for a reply, the message. Internal notes are never sent. When your system does not accept an event, it is tried again after 1, 5 and 15 minutes, then after 1, 3, 6, 12 and 24 hours. After 15 failures in a row the webhook is turned off and the administrators are told; fix your system, then select Turn on (events from then on are sent). Deliveries shows what was sent, and Try again sends a failed one again.

Checking an event (for your developer)

Each event carries the header Astro-Signature: t=<time>,v1=<signature>. Compute the HMAC-SHA256 of the text <time>.<the raw body> with the signing secret, written as lower-case hexadecimal, and compare it with v1. Refuse the event when they differ, or when the time is more than five minutes from your clock. The header Astro-Delivery is the event's id: an event can arrive twice, so ignore an id you have seen before.

Related