{"openapi":"3.1.0","info":{"title":"Triage API","version":"1.0.0","description":"Score an inbound travel enquiry and read back the stored results. The scorer is the one that reads forwarded mail: six calibrated judgments combined by a fixed formula, plus a second model that reports the facts. Triage keeps, per enquiry, only the label, score, priority, one-line summary, the sender display name, the channel and the status. The message, the sender address, the reasons and the reply draft are returned to you and not stored. You hold them. Nothing is ever sent to the traveller or to the advisor by this API. Webhooks push each scored enquiry to your HTTPS endpoints, signed. Triage does not store what a webhook carries (the reasons and the reply draft): the receiver holds them."},"servers":[{"url":"https://triage.tripcreator.ai"}],"security":[{"bearerAuth":[]}],"paths":{"/v1/score":{"post":{"operationId":"scoreInquiry","summary":"Score an enquiry","description":"Scores one enquiry and returns the verdict, the facts read from it and a reply draft. Repeat calls with the same external_id (or the same Idempotency-Key header, or the same content) answer a duplicate with the stored id and no verdict: keep the first response. Each key allows 120 requests per hour.","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"Dedupes repeat calls when external_id is not set. At most 200 characters.","schema":{"type":"string","maxLength":200}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ScoreRequest"}}}},"responses":{"200":{"description":"Scored, or a duplicate of an earlier call.","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/ScoreResponse"},{"$ref":"#/components/schemas/Duplicate"}]}}}},"400":{"description":"The request is not valid JSON or a field is out of range.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"The key is missing, malformed, unknown or revoked.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"The account has no active plan (error plan_inactive).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"The key is over its limit of 120 requests per hour, counted across all servers in fixed hourly windows. The Retry-After header gives the seconds until the window ends.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Scoring is busy or not configured. Retry later.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/inquiries":{"get":{"operationId":"listInquiries","summary":"List stored enquiries","description":"Lists what Triage keeps for the account, newest first, at most 200 rows. Team and test enquiries are left out.","parameters":[{"name":"days","in":"query","required":false,"description":"How many days back to read.","schema":{"type":"integer","minimum":1,"maximum":90,"default":7}}],"responses":{"200":{"description":"The stored rows.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InquiryList"}}}},"400":{"description":"days is not a whole number from 1 to 90.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"The key is missing, malformed, unknown or revoked.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"The key is over its limit of 120 requests per hour, counted across all servers in fixed hourly windows. The Retry-After header gives the seconds until the window ends.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/webhooks":{"get":{"operationId":"listWebhooks","summary":"List webhook endpoints","description":"Lists the account's webhook endpoints. The signing secret is shown once, when the endpoint is made, and is not listed.","responses":{"200":{"description":"The endpoints.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookList"}}}},"401":{"description":"The key is missing, malformed, unknown or revoked.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"The key is over its hourly limit.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"createWebhook","summary":"Register a webhook endpoint","description":"Registers an HTTPS endpoint (up to 5 per account) and returns its signing secret, once. The URL must be https on port 443 with a public host name: no IP address, no localhost, nothing ending in .internal or .local, no username or password, at most 2048 characters. Built for Zapier REST hooks: subscribe here, unsubscribe with DELETE.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookRequest"}}}},"responses":{"201":{"description":"Registered. Store the secret now: it is not shown again.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookCreated"}}}},"400":{"description":"The body is not valid JSON, or the URL is refused (error invalid_url).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"The key is missing, malformed, unknown or revoked.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The account already holds 5 endpoints (error limit_reached).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"The key is over its hourly limit.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/webhooks/{id}":{"delete":{"operationId":"deleteWebhook","summary":"Delete a webhook endpoint","description":"Removes the endpoint. Nothing more is sent to it.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"The id from the create answer, starting wh_."}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookDeleted"}}}},"401":{"description":"The key is missing, malformed, unknown or revoked.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No endpoint with that id on this account (error not_found).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"The key is over its hourly limit.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"webhooks":{"inquiry.scored":{"post":{"operationId":"inquiryScoredEvent","summary":"An enquiry was scored","security":[],"description":"Posted to every active endpoint for each scored enquiry that is not a team or test one, from forwarded mail, website forms and POST /v1/score. Headers: Triage-Event-Id (evt_ and 24 hex characters, the same for every attempt) and Triage-Signature (t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" under the endpoint secret>). Answer with any 2xx within 5 seconds. A network error, a 5xx and a 429 are retried after 1 s and after 3 s; any other status, a redirect included, is final. After 100 failed deliveries in a row the endpoint is switched off until you re-enable it on the account page.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookEvent"}}}},"responses":{"200":{"description":"Received. Any 2xx counts."}}}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"An API key from the Triage account page, starting trk_. An account holds up to 5 active keys. Keep it server-side."}},"schemas":{"ScoreRequest":{"type":"object","required":["body"],"additionalProperties":false,"properties":{"subject":{"type":"string","maxLength":300,"description":"The subject line, if there is one."},"body":{"type":"string","minLength":20,"maxLength":20000,"description":"The enquiry text. Read once to score it and not stored."},"sender":{"type":"string","maxLength":320,"description":"Who wrote it: \"Name <address>\" or an address. Only the display name is kept. Addresses on example.com, example.org, example.net and tripcreator.ai are treated as tests (see test in the response).","examples":["Sarah Miller <sarah.miller@gmail.com>"]},"external_id":{"type":"string","maxLength":200,"description":"Your own id for the enquiry. A repeat with the same value answers a duplicate."}}},"ScoreResponse":{"type":"object","required":["id","label","score","priority","confidence","summary","reasons","reply_draft","opening_line","language","channel","extraction","test"],"properties":{"id":{"type":"string","description":"The stored row id, api- followed by 24 hex characters."},"label":{"type":"string","enum":["HOT","WARM","COLD","SKIP","FRAUD"]},"score":{"type":"integer","minimum":0,"maximum":100},"priority":{"type":"string","enum":["reply first","reply today","reply this week","no reply needed","do not reply"]},"confidence":{"type":"number","minimum":0,"maximum":1},"summary":{"type":["string","null"],"description":"One line. This is kept."},"reasons":{"type":"array","items":{"type":"string"},"description":"Why it scored this way. Not stored."},"reply_draft":{"type":["string","null"],"description":"A sendable first reply. Null for SKIP and FRAUD. Not stored."},"opening_line":{"type":["string","null"],"description":"A suggested first line. Null for SKIP and FRAUD. Not stored."},"language":{"type":["string","null"],"description":"BCP-47 tag of the enquiry. Reasons and drafts are written in it."},"channel":{"type":"string","const":"api"},"extraction":{"type":"object","required":["destination","dates","travellers","budget","trip_type"],"description":"Facts the message states. Null when it does not say, or when extraction was unavailable. Not stored.","properties":{"destination":{"type":["string","null"]},"dates":{"type":["string","null"]},"travellers":{"type":["string","null"]},"budget":{"type":["string","null"]},"trip_type":{"type":["string","null"]}}},"test":{"type":"boolean","description":"True when the sender is our team or a test address. Such a row is stored but never listed or counted."}}},"Duplicate":{"type":"object","required":["status","id"],"properties":{"status":{"type":"string","const":"duplicate"},"id":{"type":"string"}}},"InquiryList":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Inquiry"}}}},"Inquiry":{"type":"object","required":["id","received_at","label","score","priority","summary","from","channel","status"],"properties":{"id":{"type":"string"},"received_at":{"type":"string","format":"date-time"},"label":{"type":"string","enum":["HOT","WARM","COLD","SKIP","FRAUD"]},"score":{"type":"integer","minimum":0,"maximum":100},"priority":{"type":"string","enum":["reply first","reply today","reply this week","no reply needed","do not reply"]},"summary":{"type":["string","null"]},"from":{"type":"string","description":"The sender display name. Empty when the sender was a bare address."},"channel":{"type":["string","null"]},"status":{"type":"string","enum":["new","replied","won","lost"],"description":"The advisor-set lead state."}}},"WebhookRequest":{"type":"object","required":["url"],"additionalProperties":false,"properties":{"url":{"type":"string","maxLength":2048,"format":"uri","description":"Where to post events: https, port 443, a public host name.","examples":["https://hooks.example.com/triage"]}}},"WebhookCreated":{"type":"object","required":["id","url","secret","created_at"],"properties":{"id":{"type":"string","description":"wh_ followed by 12 hex characters."},"url":{"type":"string"},"secret":{"type":"string","description":"whsec_ followed by 32 characters. Signs every event to this endpoint. Shown once."},"created_at":{"type":"string","format":"date-time"}}},"WebhookList":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Webhook"}}}},"Webhook":{"type":"object","required":["id","url","status","created_at"],"properties":{"id":{"type":"string"},"url":{"type":"string"},"status":{"type":"string","enum":["active","disabled"],"description":"An endpoint is disabled after 100 failed deliveries in a row."},"created_at":{"type":"string","format":"date-time"}}},"WebhookDeleted":{"type":"object","required":["id","deleted"],"properties":{"id":{"type":"string"},"deleted":{"type":"boolean","const":true}}},"WebhookEvent":{"type":"object","required":["id","type","created","test","data"],"properties":{"id":{"type":"string","description":"evt_ and 24 hex characters. Also sent as Triage-Event-Id; dedupe on it."},"type":{"type":"string","const":"inquiry.scored"},"created":{"type":"integer","description":"Unix seconds."},"test":{"type":"boolean","description":"True for the sample sent by \"Send test\" on the account page."},"data":{"type":"object","required":["inquiry_id","received_at","label","score","priority","confidence","summary","reasons","reply_draft","opening_line","language","channel","from"],"properties":{"inquiry_id":{"type":"string","description":"The id of the stored row, as GET /v1/inquiries lists it."},"received_at":{"type":"string","format":"date-time"},"label":{"type":"string","enum":["HOT","WARM","COLD","SKIP","FRAUD"]},"score":{"type":"integer","minimum":0,"maximum":100},"priority":{"type":"string","enum":["reply first","reply today","reply this week","no reply needed","do not reply"]},"confidence":{"type":"number","minimum":0,"maximum":1},"summary":{"type":["string","null"],"description":"One line. Triage keeps this."},"reasons":{"type":"array","items":{"type":"string"},"description":"Why it scored this way. Triage does not keep them."},"reply_draft":{"type":["string","null"],"description":"A sendable first reply. Null for SKIP and FRAUD. Triage does not keep it."},"opening_line":{"type":["string","null"],"description":"A suggested first line. Null for SKIP and FRAUD. Triage does not keep it."},"language":{"type":["string","null"],"description":"BCP-47 tag of the enquiry."},"channel":{"type":"string","description":"How the enquiry arrived, such as website_form, api or direct."},"from":{"type":"string","description":"The sender display name only. Never an address. Empty when the sender was a bare address."}}}}},"Error":{"type":"object","required":["error","message"],"properties":{"error":{"type":"string","description":"A stable code, such as unauthorised, plan_inactive, rate_limited or limit_reached."},"message":{"type":"string"}}}}}}