Skip to content
QwryAI
Documentation
Pages

Endpoints

Send an event

Start a procedure for one contact when something happens in your own system

When something happens in your system, such as an order shipping, a trial ending or a payment failing, you can have your agent reach out about it. Give a procedure the API trigger and publish it, then call the start_procedure_for_contact tool with the procedure and the contact. The agent writes to the contact on the procedure's channel and handles their reply.

POSThttps://api.qwryai.com/public/v1/tools/start_procedure_for_contact

Like every change made through the Tools API, the call returns a review first. The procedure starts when you apply the review with POST https://api.qwryai.com/public/v1/reviews/{reviewId}/apply, within 15 minutes.

Authentication

Send your API key as Authorization: Bearer YOUR_API_KEY. The key needs Change actions and procedures. See Authentication.

Body parameters

NameTypeRequiredDescription
chatbotIdstringYesThe agent's id, from list_agents.
procedure_idstringYesThe procedure's id, as automation_drafts lists it. See List procedures.
contactobjectYesThe contact to start it for, named by exactly one of the fields below.
contact.contact_idstringOne ofThe contact's identifier in QwryAI.
contact.emailstringOne ofThe contact's email address.
contact.phonestringOne ofThe contact's phone number in international format, such as +14155550123.
contact.external_idstringOne ofThe id your own system gave the contact.

To stop a procedure for a contact once they've done what it was for, such as finishing onboarding, call finish_procedure_for_contact with the same body. Their repeated messages stop and the procedure's report counts them as finished.

Request example

Bash
curl -X POST 'https://api.qwryai.com/public/v1/tools/start_procedure_for_contact' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "chatbotId": "YOUR_AGENT_ID",
    "procedure_id": "PROCEDURE_ID",
    "contact": { "email": "sam.tester@example.com" }
  }'

# Then apply the review it returned
curl -X POST 'https://api.qwryai.com/public/v1/reviews/REVIEW_ID/apply' \
  -H 'Authorization: Bearer YOUR_API_KEY'

Response

JSON
{
  "success": true,
  "data": {
    "status": "review_required",
    "reviewId": "9d2f4b7e-6a1c-4c3e-8f5a-1b2c3d4e5f60",
    "tool": "start_procedure_for_contact",
    "changes": [
      {
        "title": "Start \"Order shipped\" for Sam Tester",
        "before": null,
        "after": { "procedure": "Order shipped", "contact": "Sam Tester", "channel": "Email" }
      }
    ],
    "unchanged": [],
    "expiresAt": "2026-12-01T10:15:00.000Z",
    "next": "Show these changes to the user. Call apply_change with this reviewId only after they approve; the review expires in 15 minutes."
  }
}

Each start costs one credit. A contact with no address on the procedure's channel is skipped. Follow each start on the procedure's Runs.

Errors

HTTP statuscodeWhen
400INVALID_ARGUMENTSThe body fails the schema, contact names none or more than one field, no contact matches, no procedure has that id, or the procedure can't start: it isn't published, has no API trigger, or its channel can't send. message gives the reason.
400CHATBOT_ID_REQUIREDchatbotId is missing or isn't a valid agent id.
403INSUFFICIENT_PERMISSIONThe key doesn't hold Change actions and procedures.
404CHATBOT_NOT_FOUNDNo agent with that chatbotId in your workspace.
404REVIEW_NOT_FOUNDOn apply: no review with that id for this key.
409REVIEW_EXPIREDOn apply: more than 15 minutes passed. Call the tool again.
409REVIEW_ALREADY_USEDOn apply: the review was already applied.
409STALE_REVIEWOn apply: the procedure or contact changed after the review. Call the tool again.
409VALIDATION_INVALID_BODYOn apply: the procedure can no longer start, for example because it was paused. message gives the reason.

See Error Handling for authentication and rate-limit errors.

Explore the documentation