# Attach webhook

`POST https://app.shuttleglobal.com/c/api/instances/{instance_key}/webhooks`

Adds a URL to the instance's `webhook_target`, alongside any URLs already there (see [Webhook configuration](/platforms/reference/webhooks/#webhook-configuration)).
Attaching a URL that is already attached updates its `retries` instead of adding it again.

## Authentication

- basicAuth: Basic Authentication using secret key
- bearerAuth: OAuth 2.0 Bearer Token Authentication

## Request body (`application/json`), required

- `webhook` (object, required)
  - `url` (string (uri), required): The HTTPS URL that will receive webhooks
  - `retries` (integer): The total number of delivery attempts for each webhook, including the first. For example, `3` means the first attempt plus up to two retries. Leave it out (or send `0` or `1`) for a single attempt with no retries.

## Responses

### 200: Webhook successfully attached

```json
{
  "webhook": {
    "id": "5d41402abc4b2a76b9719d911017c592",
    "url": "https://your-app.com/webhooks/shuttle",
    "retries": 3
  }
}
```

### 400: Bad request

```json
{
  "code": "string",
  "message": "string"
}
```

### 401: Authentication required

```json
{
  "code": "UNAUTHORIZED",
  "message": "Unauthorised"
}
```

## Example request

```sh
curl --request POST \
  --url https://app.shuttleglobal.com/c/api/instances/YOUR_INSTANCE_KEY/webhooks \
  --header 'Authorization: Basic <base64 of SECRET_KEY:>' \
  --header 'Content-Type: application/json' \
  --data '{
  "webhook": {
    "url": "https://your-app.com/webhooks/shuttle",
    "retries": 3
  }
}'
```

Reference page: https://docs.shuttleglobal.com/platforms/reference/instance-webhooks/operations/attachwebhook/