# The trigger address an outside program calls.

> Needs no session or API key: it is authenticated only by the automation's own secret.
> https://koi.dog/docs/api/automations/trigger-automation/

`POST /api/v1/automations/{id}/trigger` · Key: `none`

A `koidog` trigger takes `Authorization: Bearer kdt_...`, or `Koidog-Timestamp` and `Koidog-Signature: v1=<hex HMAC-SHA256 of "<timestamp>.<raw body>">` (five minutes either way). A `github` trigger takes GitHub's `X-Hub-Signature-256`, `X-GitHub-Event` and `X-GitHub-Delivery`. A delivery id already seen is refused (`409 replayed`). Bodies over 256 KB are refused (`413`), and each automation takes at most 30 calls a minute. Answers at once with the run it recorded (`202`); the crew is launched after. An event its filter does not take (and GitHub's `ping`) answers `202` with `ignored` and records nothing. Text from the body reaches the agents only through declared placeholders, cut to length and marked as outside text. No query parameters.

## Path parameters.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | The automation's id. |

## Headers.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `Authorization` | `string` | no | `Bearer kdt_...`: the automation's trigger secret (a `koidog` trigger). Or sign the body instead, with the next two. |
| `Koidog-Timestamp` | `string` | no | The current Unix time in seconds, within five minutes of the server's. With `Koidog-Signature`. |
| `Koidog-Signature` | `string` | no | `v1=<hex HMAC-SHA256 of "<timestamp>.<raw body>">` under the trigger secret. |
| `Koidog-Delivery-Id` | `string` | no | Your id for this call. A delivery id already taken is refused with `409 replayed`. `Idempotency-Key` is read the same way when this is absent. |
| `X-Hub-Signature-256` | `string` | no | A `github` trigger: GitHub's signature of the raw body under the trigger secret. Required. |
| `X-GitHub-Event` | `string` | no | A `github` trigger: the event name, checked against the automation's events. |
| `X-GitHub-Delivery` | `string` | no | A `github` trigger: GitHub's delivery id. Required; a repeat is refused with `409 replayed`. |

## Body.

Any JSON object, or nothing. It is read raw, so a signature covers these exact bytes. At most 256 KB (`413 too_large` otherwise). Its values reach the agents only through the automation's `inputs` placeholders, cut to `guards.maxInputChars` and marked as outside text.

## Response.

202 Accepted: a JSON object. The work continues and is reported on the timeline. The example has placeholder values.

## Request.

```sh
curl -X POST "https://app.koi.dog/api/v1/automations/$ID/trigger" \
    -H "Authorization: Bearer $KOIDOG_TRIGGER_SECRET" \
    -H "Koidog-Delivery-Id: $(uuidgen)" \
    -H "Content-Type: application/json" \
    -d '{
      "issue": {
        "title": "Login page is blank on Safari",
        "number": 412
      }
    }'
```

```js
const res = await fetch(`https://app.koi.dog/api/v1/automations/${process.env.ID}/trigger`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.KOIDOG_TRIGGER_SECRET}`,
    "Koidog-Delivery-Id": crypto.randomUUID(),
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    issue: {
      title: "Login page is blank on Safari",
      number: 412,
    },
  }),
});
console.log(await res.json());
```

```python
import os
import uuid

import requests

r = requests.post(
    f"https://app.koi.dog/api/v1/automations/{os.environ['ID']}/trigger",
    headers={
        "Authorization": f"Bearer {os.environ['KOIDOG_TRIGGER_SECRET']}",
        "Koidog-Delivery-Id": str(uuid.uuid4()),
    },
    json={
        "issue": {
            "title": "Login page is blank on Safari",
            "number": 412,
        },
    },
)
r.raise_for_status()
print(r.json())
```

## Response example.

```json
{
  "run": {
  },
  "ignored": "string"
}
```
