# 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. ```http POST https://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. > [!NOTE] > > Only a live procedure with the **API** trigger can start this way. Add the trigger in the procedure's editor, where its chip reads **API or Contacts**. A start sends on the procedure's one channel: Email, WhatsApp or the website chat of a signed-in contact. See [Procedures](/docs/user-guides/chatbot/procedures/procedures-overview). ## Authentication Send your API key as `Authorization: Bearer YOUR_API_KEY`. The key needs **Change actions and procedures**. See [Authentication](/docs/api-reference/v2/authentication). ## Body parameters | Name | Type | Required | Description | | - | - | - | - | | `chatbotId` | string | Yes | The agent's id, from `list_agents`. | | `procedure_id` | string | Yes | The procedure's id, as `automation_drafts` lists it. See [List procedures](/docs/api-reference/v2/procedures/list-procedures). | | `contact` | object | Yes | The contact to start it for, named by exactly one of the fields below. | | `contact.contact_id` | string | One of | The contact's identifier in QwryAI. | | `contact.email` | string | One of | The contact's email address. | | `contact.phone` | string | One of | The contact's phone number in international format, such as `+14155550123`. | | `contact.external_id` | string | One of | The 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 > [tab] cURL > > ```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' > ``` > [tab] JavaScript > > ```javascript > const headers = { Authorization: "Bearer YOUR_API_KEY", "Content-Type": "application/json" }; > > const prepared = await fetch("https://api.qwryai.com/public/v1/tools/start_procedure_for_contact", { > method: "POST", > headers, > body: JSON.stringify({ > chatbotId: "YOUR_AGENT_ID", > procedure_id: "PROCEDURE_ID", > contact: { email: "sam.tester@example.com" }, > }), > }).then((response) => response.json()); > > const applied = await fetch( > `https://api.qwryai.com/public/v1/reviews/${prepared.data.reviewId}/apply`, > { method: "POST", headers }, > ).then((response) => response.json()); > console.log(applied.data.status); // "succeeded" > ``` > [tab] Python > > ```python > import requests > > headers = {"Authorization": "Bearer YOUR_API_KEY"} > prepared = requests.post( > "https://api.qwryai.com/public/v1/tools/start_procedure_for_contact", > headers=headers, > json={ > "chatbotId": "YOUR_AGENT_ID", > "procedure_id": "PROCEDURE_ID", > "contact": {"email": "sam.tester@example.com"}, > }, > ).json() > > applied = requests.post( > f"https://api.qwryai.com/public/v1/reviews/{prepared['data']['reviewId']}/apply", > headers=headers, > ).json() > ``` ## Response > [tab] Review > > ```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." > } > } > ``` > [tab] Apply > > ```json > { > "success": true, > "data": { > "status": "succeeded", > "reviewId": "9d2f4b7e-6a1c-4c3e-8f5a-1b2c3d4e5f60", > "tool": "start_procedure_for_contact", > "data": { > "applied": true, > "sendId": "", > "coverage": "Started. The contact gets the procedure's message shortly; follow it on the procedure's Runs." > }, > "receipt": { "applied": true, "sendId": "" } > } > } > ``` 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 status | code | When | | - | - | - | | 400 | `INVALID_ARGUMENTS` | The 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. | | 400 | `CHATBOT_ID_REQUIRED` | `chatbotId` is missing or isn't a valid agent id. | | 403 | `INSUFFICIENT_PERMISSION` | The key doesn't hold **Change actions and procedures**. | | 404 | `CHATBOT_NOT_FOUND` | No agent with that `chatbotId` in your workspace. | | 404 | `REVIEW_NOT_FOUND` | On apply: no review with that id for this key. | | 409 | `REVIEW_EXPIRED` | On apply: more than 15 minutes passed. Call the tool again. | | 409 | `REVIEW_ALREADY_USED` | On apply: the review was already applied. | | 409 | `STALE_REVIEW` | On apply: the procedure or contact changed after the review. Call the tool again. | | 409 | `VALIDATION_INVALID_BODY` | On apply: the procedure can no longer start, for example because it was paused. `message` gives the reason. | See [Error Handling](/docs/api-reference/v2/error-handling) for authentication and rate-limit errors.