# Create a webhook

`POST https://api.fiscalisto.com/v1/webhook_endpoints`

The response carries the signing secret (secret) only once.

## Before you call

- **A key for the whole account**: not limited to some issuers or to a test environment.

## Parameters

| Name | In | Required | Description |
| --- | --- | --- | --- |
| `Idempotency-Key` | header |  | Optional (the SDKs send it on their own). If the response is lost, repeat the request with the same value within 24 hours: it answers the same, with idempotent-replayed: true, and doesn't do it twice (it doesn't create, send emails or charge). |

## Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `url` | string | yes | https address on your server that receives the notices. (up to 2048 characters) |
| `events` | array of string or null |  | Events you want to receive, or ["*"] for all (the default). The list with when each one arrives: [Event types](https://fiscalisto.com/en/docs/api/webhooks#tipos-de-evento). |
| `description` | string or null |  | What it's for, for you (it isn't sent in the events). |
| `api_version` | string or null |  | The API version its events arrive in (for example 2026-10-24); null or not sent: the account's. That way you update one endpoint at a time. |

Example:

```json
{
  "url": "https://mi-plataforma.mx/webhooks/fiscalisto",
  "events": [
    "invoice.stamped",
    "invoice.failed",
    "invoice.canceled"
  ]
}
```

## With the TypeScript SDK

```ts
import { Fiscalisto } from "fiscalisto";

// La llave viene de FISCALISTO_API_KEY.
const fiscalisto = new Fiscalisto();

const webhookEndpoint = await fiscalisto.webhookEndpoints.create({
  url: "https://mi-plataforma.mx/webhooks/fiscalisto",
  events: [
    "invoice.stamped",
    "invoice.failed",
    "invoice.canceled",
  ],
}, { idempotencyKey: "pedido-A-1042" });
```

## With the Python SDK

```python
from fiscalisto import Fiscalisto

# La llave viene de FISCALISTO_API_KEY.
fiscalisto = Fiscalisto()

webhook_endpoint = fiscalisto.webhook_endpoints.create({
    "url": "https://mi-plataforma.mx/webhooks/fiscalisto",
    "events": [
        "invoice.stamped",
        "invoice.failed",
        "invoice.canceled",
    ],
}, idempotency_key="pedido-A-1042")
```

## With the PHP SDK

```php
<?php

use Fiscalisto\Fiscalisto;

// La llave viene de FISCALISTO_API_KEY.
$fiscalisto = new Fiscalisto();

$webhookEndpoint = $fiscalisto->webhookEndpoints->create([
    'url' => 'https://mi-plataforma.mx/webhooks/fiscalisto',
    'events' => [
        'invoice.stamped',
        'invoice.failed',
        'invoice.canceled',
    ],
], ['idempotency_key' => 'pedido-A-1042']);
```

## With the .NET SDK

```csharp
using Fiscalisto;

// La llave viene de FISCALISTO_API_KEY.
var fiscalisto = new FiscalistoClient();

var webhookEndpoint = await fiscalisto.WebhookEndpoints.CreateAsync(new CreateWebhookEndpointParams
{
    Url = "https://mi-plataforma.mx/webhooks/fiscalisto",
    Events = new()
    {
        "invoice.stamped",
        "invoice.failed",
        "invoice.canceled",
    },
}, new RequestOptions { IdempotencyKey = "pedido-A-1042" });
```

## With the Go SDK

```go
package main

import (
	"context"
	"fmt"
	"log"

	fiscalisto "fiscalisto.com/go"
)

func main() {
	// La llave viene de FISCALISTO_API_KEY.
	client, err := fiscalisto.NewClient("")
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()

	webhookEndpoint, err := client.WebhookEndpoints.Create(ctx, &fiscalisto.CreateWebhookEndpointParams{
		URL: "https://mi-plataforma.mx/webhooks/fiscalisto",
		Events: []string{
			"invoice.stamped",
			"invoice.failed",
			"invoice.canceled",
		},
	}, fiscalisto.WithIdempotencyKey("pedido-A-1042"))
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(webhookEndpoint.ID)
}
```

## With the Java SDK

```java
import com.fiscalisto.FiscalistoClient;
import com.fiscalisto.RequestOptions;
import com.fiscalisto.model.CreateWebhookEndpointParams;
import java.util.List;

// La llave viene de FISCALISTO_API_KEY.
var fiscalisto = new FiscalistoClient();

var webhookEndpoint = fiscalisto.webhookEndpoints().create(new CreateWebhookEndpointParams()
        .setUrl("https://mi-plataforma.mx/webhooks/fiscalisto")
        .setEvents(List.of(
                "invoice.stamped",
                "invoice.failed",
                "invoice.canceled"
        )), RequestOptions.idempotencyKey("pedido-A-1042"));
System.out.println(webhookEndpoint.getId());
```

## Response 201

OK.

A `WebhookEndpoint` object:

| Field | Type | Always present | Description |
| --- | --- | --- | --- |
| `id` | string | yes | Object identifier, with its prefix (iss_, inv_, ret_, cus_, prd_, emp_, bat_, brn_, whs_, stm_, adj_, evt_, whe_). |
| `livemode` | boolean | yes | true in production (fk_live_ keys), false in test mode (fk_test_). Test objects aren't valid before the SAT. |
| `object` | `"webhook_endpoint"` | yes | What kind of object it is («invoice», «customer»…). |
| `sandbox` | string or null | yes | The sandbox (sbx_…) it belongs to, or null if it belongs to the account. See /v1/sandboxes. |
| `url` | string | yes | https address on your server that receives the notices. |
| `description` | string or null | yes | What it is for, for you. |
| `events` | array of string | yes | Events you want to receive, or ["*"] for all (the default). The list with when each one arrives: [Event types](https://fiscalisto.com/en/docs/api/webhooks#tipos-de-evento). |
| `status` | `enabled`, `failing`, `disabled` | yes | enabled: delivering. failing: its deliveries fail (it turns off after 5 days like that). disabled: off. |
| `disabled_reason` | string or null |  | Why it turned off: failing (its deliveries failed 5 days in a row), gone (your server answered 410 Gone) or manual (you turned it off). |
| `failing_since` | string (date-time) or null |  | Since when deliveries have been failing, or null. |
| `previous_secret_expires_at` | string (date-time) or null | yes | Until when the previous secret also signs (after rotating it), or null. |
| `api_version` | string or null | yes | The API version of its events; null: the account's. |
| `created_at` | string (date-time) or null | yes | When it was created, ISO 8601 with Mexico City time (-06:00). |
| `secret` | string |  | Signing secret (whsec_…). It only comes when it is created or rotated: save it to verify signatures. |

```json
{
  "id": "whe_0q1Vmmw52sbDpmtsKD1E",
  "object": "webhook_endpoint",
  "livemode": false,
  "sandbox": null,
  "url": "https://mi-plataforma.mx/webhooks/fiscalisto",
  "description": null,
  "events": [
    "invoice.stamped"
  ],
  "status": "enabled",
  "disabled_reason": null,
  "failing_since": null,
  "previous_secret_expires_at": null,
  "api_version": null,
  "created_at": "2026-10-24T10:15:42-06:00",
  "secret": "whsec_MfKQ9r7Cq1ZzR0nN3xY2bW8eT5uV6sA4"
}
```

## Errors

- `api_version_invalid` (400): There's no such API version (in Fiscalisto-Version or api_version). See Versiones in the docs for the ones there are.
- `endpoint_exists` (400): There's already a webhook endpoint with that URL in this mode (the message says which): update it instead of creating another.
- `endpoint_limit` (400): The account has the most webhook endpoints allowed in this mode.
- `key_restricted` (403): This key is limited to some issuers and the request touches another one (or creates one, or uses something of the whole account, like webhooks).

Plus those of any call (key, fields, limits): https://fiscalisto.com/en/docs/api/errores.md.
