> For the complete documentation index, see [llms.txt](https://docs.tryterra.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tryterra.co/reference/teams-api/event-types.md).

# Event types

The webhook events the Teams API sends, what triggers each one, and its payload.

The Teams API sends these events to your destination when coaches and athletes register or are deleted, and when requested data is ready.

{% hint style="info" %}
Every request to Terra, and every event from Terra, carries a `terra-reference` header with a unique identifier for the request or event.

When a request for data leads to data being sent to your server asynchronously, the request and the event share the same `terra-reference`. Use it to track whether a data request has been fulfilled or is still pending.
{% endhint %}

## Coach

<details>

<summary>Coach registration</summary>

**Slug:**

`coach.registered`

**Trigger:**

A [coach](https://docs.tryterra.co/teams-api/getting-started#coaches) has authenticated under your dev ID.

**Recommended action:**

Save the [coach](https://docs.tryterra.co/teams-api/getting-started#coaches) to your database.

**Format:**

```json
{
  "data": Coach,
  "message": "Coach has successfully registered",
  "type": "coach.registered"
}
```

</details>

## Athlete

<details>

<summary>Athlete creation</summary>

**Slug:**

`athlete.registered`

**Trigger:**

One or more athletes have been registered under an associated coach.

**Recommended action:**

Save the [athletes](https://docs.tryterra.co/teams-api/getting-started#athletes) to your database, and send a `PATCH` for each athlete to attach its reference ID.

**Format:**

```json
{
  "data": Coach,
  "message": "One or more Athletes have been successfully registered",
  "type": "athlete.registered"
}
```

</details>

<details>

<summary>Athlete deletion</summary>

**Slug:**

`athlete.deleted`

**Trigger:**

One or more athletes have been deleted.

**Recommended action:**

Remove the [athletes](https://docs.tryterra.co/teams-api/getting-started#athletes)' information from your database as your requirements dictate, or record that they have been deleted on the provider's system.

**Format:**

```json
{
  "data": [athlete],
  "message": "One or more Athletes have been deleted",
  "type": "athlete.deleted"
}
```

</details>

## Data requests

<details>

<summary>Tests retrieved</summary>

**Slug:**

`test.retrieved`

**Trigger:**

One or more tests have been retrieved.

**Recommended action:**

Save the test data as your requirements dictate, and update existing tests by their unique IDs.

**Format:**

```json
{
  "data": [Test],
  "coach": Coach,
  "type": "test.retrieved"
}
```

</details>

<details>

<summary>Activities retrieved</summary>

**Slug:**

`activity.retrieved`

**Trigger:**

One or more activities have been retrieved.

**Recommended action:**

Save the activity data as your requirements dictate, and update existing activities by their unique IDs.

**Format:**

```json
{
  "data": [Activity],
  "coach": Coach,
  "type": "activity.retrieved"
}
```

</details>
