# Create an endpoint (/docs/api-reference/hooks-endpoints/create-hook-endpoint)

Registers a URL of the application's user that receives its messages, each request signed (Standard Webhooks) with the endpoint's own secret, returned here. Usually your users add endpoints themselves in the portal. Hooks resources belong to the API key's own environment: a `coss_test_…` key only ever sees sandbox ones, a `coss_live_…` key only production ones.

`POST https://api.coss.com/v1/hooks/applications/{application}/endpoints`

Authenticate with your API key as a bearer token (`Authorization: Bearer coss_test_…`). Responses are JSON with snake_case fields; errors are `{ error: { type, code, message, param?, issues?, request_id } }` (https://coss.com/docs/api-reference/errors.md).

## Path parameters

- `application` (string, required): The application's `id` (`happ_…`) or your `uid` for it.

## Request body

- `url` (string, required, at most 2048 characters)
- `description` (string, at most 256 characters): Your note about it.
- `filter_types` (string[], at most 250 items): Event types delivered to this endpoint (existing, unarchived ones). An empty array means every type, including ones added later.
- `secret` (string): A `whsec_` + base64 secret of 24-64 bytes to sign with, e.g. when migrating from another provider. Generated when omitted.
- `rate_limit_per_second` (integer, 1-1000): At most this many requests per second to this endpoint.
- `metadata` (map of string): Your own key-value pairs (at most 16; keys up to 40 characters, values up to 500).
- `enabled` (boolean): Default `true`. `false` creates it disabled, with `disabled_reason: manual`.

## Example request

TypeScript (the `coss` package):

```ts
import { Coss } from "coss";

const coss = new Coss({
  apiKey: process.env.COSS_API_KEY,
  baseUrl: "https://api.coss.com",
});

const { data, error } = await coss.hooks.endpoints.create("customer_8812", {
  url: "https://example.com/webhooks",
  filter_types: [
    "invoice.paid",
  ],
});
```

HTTP:

```sh
curl -X POST "https://api.coss.com/v1/hooks/applications/customer_8812/endpoints" \
  -H "Authorization: Bearer $COSS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "url": "https://example.com/webhooks",
  "filter_types": [
    "invoice.paid"
  ]
}'
```

Python:

```python
from coss import Coss

client = Coss()  # api_key= or COSS_API_KEY

client.hooks.endpoints.create(
    application="customer_8812",
    url="https://example.com/webhooks",
    filter_types=[
        "invoice.paid"
    ],
)
```

Go:

```go
import (
	"context"

	cossclient "github.com/cosscom/coss-go/client"
	hooks "github.com/cosscom/coss-go/hooks"
)

client := cossclient.NewClient() // option.WithAPIKey(…) or COSS_API_KEY

request := &hooks.CreateHookEndpointRequest{
    Application: "customer_8812",
    URL: "https://example.com/webhooks",
    FilterTypes: []string{
        "invoice.paid",
    },
}
client.Hooks.Endpoints.Create(
    context.TODO(),
    request,
)
```

Ruby:

```ruby
require "coss"

client = Coss::Client.new # api_key: or COSS_API_KEY

client.hooks.endpoints.create(
  application: "customer_8812",
  url: "https://example.com/webhooks",
  filter_types: ["invoice.paid"]
)
```

PHP:

```php
<?php

use Coss\Coss;
use Coss\Hooks\Endpoints\Requests\CreateHookEndpointRequest;

$client = new Coss(); // apiKey: or COSS_API_KEY

$client->hooks->endpoints->create(
    'customer_8812',
    new CreateHookEndpointRequest([
        'url' => 'https://example.com/webhooks',
        'filterTypes' => [
            'invoice.paid',
        ],
    ]),
);
```

Java:

```java
import com.coss.Coss;
import com.coss.resources.hooks.endpoints.requests.CreateHookEndpointRequest;
import java.util.Arrays;
import java.util.Optional;

Coss client = Coss.builder().build(); // .apiKey(…) or COSS_API_KEY

client.hooks().endpoints().create(
    "customer_8812",
    CreateHookEndpointRequest
        .builder()
        .url("https://example.com/webhooks")
        .filterTypes(
            Optional.of(
                Arrays.asList("invoice.paid")
            )
        )
        .build()
);
```

.NET:

```csharp
using Coss;
using Coss.Hooks;

var client = new CossClient(); // apiKey: or COSS_API_KEY

await client.Hooks.Endpoints.CreateAsync(
    new CreateHookEndpointRequest
    {
        Application = "customer_8812",
        Url = "https://example.com/webhooks",
        FilterTypes = new List<string>() { "invoice.paid" },
    }
);
```

## Response 200

The endpoint and its signing secret.

- `object` ("hook_endpoint", required)
- `id` (string, required)
- `application_id` (string, required): The id of the application it belongs to.
- `url` (string, required): Where deliveries are sent.
- `description` (string | null, required): Your note about it. `null`: none.
- `filter_types` (string[], required): Only these event types are delivered. Empty: every type.
- `rate_limit_per_second` (integer | null, required): At most this many requests per second to this endpoint. `null`: no limit of its own.
- `enabled` (boolean, required): Whether new messages are delivered to it.
- `disabled_reason` ("manual" | "failing" | null, required): `manual`: disabled by you or its user. `failing`: its deliveries failed every attempt for five days, so coss.com disabled it. `null` while enabled.
- `disabled_at` (string | null, required, date-time): When it was disabled. `null`: it's enabled.
- `failing_since` (string | null, required, date-time): When its current run of failed deliveries began; cleared by the next success. `null` while healthy.
- `previous_secret_expires_at` (string | null, required, date-time): After a secret roll, requests are also signed with the previous secret until then.
- `metadata` (map of string, required): Your own key-value pairs.
- `created_at` (string, required, date-time)
- `updated_at` (string, required, date-time)
- `secret` (string, required): The endpoint's `whsec_…` signing secret (Standard Webhooks).

Example:

```json
{
  "object": "hook_endpoint",
  "id": "hep_01k7c8m4q2f3e9v6t5r1n0p8yz",
  "application_id": "happ_01k7c8m4q2f3e9v6t5r1n0p8yz",
  "url": "https://example.com/webhooks",
  "description": "Production",
  "filter_types": [
    "invoice.paid"
  ],
  "rate_limit_per_second": null,
  "enabled": true,
  "disabled_reason": null,
  "disabled_at": null,
  "failing_since": null,
  "previous_secret_expires_at": null,
  "metadata": {},
  "created_at": "2026-01-15T09:30:00.000Z",
  "updated_at": "2026-01-15T09:30:00.000Z",
  "secret": "whsec_6Jk…"
}
```

## Errors

- `400`: The body is not valid JSON (`invalid_json`). Also when the `Coss-Version` header names an unknown API version (`invalid_api_version`).
- `401`: The API key is missing, invalid, revoked or expired (`authentication_error`).
- `403`: The API key lacks the permission this endpoint needs (`permission_error`), or its organization is suspended (`organization_suspended`).
- `404`: No such application, or no endpoint with this id in it (`application_not_found`, `not_found`).
- `413`: The request body is larger than 5 MB (`payload_too_large`).
- `415`: The body is not sent as `application/json` (`unsupported_media_type`).
- `422`: The body failed validation (`validation_error`), the URL is not a usable https:// URL (`invalid_url`), a filter type is unknown or archived (`unknown_event_type`), the secret is malformed (`invalid_secret`), or the application has the most endpoints it can (50 live, 5 sandbox: `too_many_endpoints`).
- `429`: Too many requests with this API key (`rate_limited`), or too many requests with invalid keys from this address (`too_many_failed_authentications`). Retry after `Retry-After` seconds. Successful responses carry `RateLimit-Limit`, `RateLimit-Remaining` and `RateLimit-Reset` (seconds until the limit is fully restored).
- `500`: Unexpected server error (`api_error` / `internal_error`).
- `503`: The API key could not be verified right now; retry (`service_unavailable`).