# Webhooks

> Keep Planning's people and teams in step with a list your team already keeps.

A webhook lets a script or a spreadsheet send tiko the workspace's people and their teams. The **Stages and people** list then follows that list: new people appear, changed teams change, people who left are archived. Nobody retypes the team in tiko. For a one-off list, **Import…** in **Settings → Stages and people** takes a pasted table or a CSV file by the same rules ([Stages and people](https://docs.tiko.run/gantt/stages/)).

## Make a webhook

1. In **Settings → Webhooks**, type a name such as "Unit people" and choose **Add webhook**. Only a workspace admin sees this section.
2. Copy the secret. It is shown once; **New secret** makes another and stops the old one at once.
3. Copy the address under the webhook's name. A sender posts to it with the secret.

Choose the webhook's name to see its last 50 deliveries: when, the answer, and what changed. What was sent is never kept.

## What to send

```bash
curl -X POST https://tiko.example.com/api/hooks/<id> \
  -H "Authorization: Bearer tikohook_…" \
  -H "Content-Type: application/json" \
  -d '{"people": [
        {"name": "Ann Lee", "key": "ann@example.com", "teams": ["Payments"]},
        {"name": "Bob Stone", "key": "bob@example.com", "teams": ["Core", "Payments"]}
      ]}'
```

- `name`, up to 80 characters, and `teams`, up to 10 names of up to 40 characters each. A new team name is a new team.
- `key` is optional: anything that stays the same for a person, such as an e-mail address or an employee number. Send it: with a key a renamed person stays the same person, and their stages stay with them. Without one tiko matches by name, and a rename becomes a new person.
- Send the whole list each time. People this webhook sent before and left out now are archived; their stages keep their name. Add `"missing": "keep"` to only add and change.
- At most 2000 people a delivery, 1 MB, and 60 deliveries an hour. A workspace holds up to 5000 people.

tiko answers what changed, for example `{"added": 2, "changed": 0, "archived": 1, "unarchived": 0, "owned_elsewhere": 0}`. A delivery applies all or nothing: a problem answers `422` and names its place, such as `people[3].teams`, and nothing changes. A wrong secret answers `401`. While Planning is off, deliveries answer `409`.

## From a spreadsheet

Keep the team in a Google Sheet with the columns `name`, `key` and `teams` (teams separated by `;`), on a sheet named `People`. In the sheet, open **Extensions → Apps Script**, paste this, and fill in the address:

```js
const ADDRESS = 'https://tiko.example.com/api/hooks/<id>'

function sendPeople() {
  // Project settings → Script properties: TIKO_SECRET = the webhook's secret.
  const secret = PropertiesService.getScriptProperties().getProperty('TIKO_SECRET')
  const [header, ...rows] = SpreadsheetApp.getActive().getSheetByName('People').getDataRange().getValues()
  const at = (name) => header.indexOf(name)
  const people = rows
    .filter((row) => String(row[at('name')]).trim())
    .map((row) => ({
      name: String(row[at('name')]).trim(),
      key: String(row[at('key')] || '').trim() || undefined,
      teams: String(row[at('teams')] || '').split(';').map((t) => t.trim()).filter(Boolean),
    }))
  UrlFetchApp.fetch(ADDRESS, {
    method: 'post',
    contentType: 'application/json',
    headers: { Authorization: `Bearer ${secret}` },
    payload: JSON.stringify({ people }),
  })
}
```

Then add a trigger in **Triggers**: `sendPeople`, time-driven, every 15 minutes. A time trigger keeps within the hourly limit, which a trigger on every edit would use up.

## People from a webhook

- **Stages and people** shows "From <webhook>" next to them. Their name and teams change only where they are sent from; time off and archiving stay in tiko.
- A person another webhook sent is left as it is and counted as `owned_elsewhere`.
- Removing a webhook keeps its people, kept by hand from then on.
- Keys stay on the server, in tiko's database and its backups. Members, guests of a public link and exported boards never get them.
