> ## Documentation Index
> Fetch the complete documentation index at: https://docs.followr.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Webhooks

> Get a request when a post is published or fails, instead of polling.

Followr sends a `POST` to your URL when a company's post changes status. There is one event today: a post was published or failed. See [Webhook events](https://docs.followr.ai/webhooks/events.md) for every status and field.

## Set the URL

Each company has its own URL and secret. Owners, admins and users can set the URL; clients can't.

> [tab] In the app
>
> **1. Open the webhook settings**
>
> Select the company, then go to [**Company settings > Webhooks**](https://app.followr.ai/company-settings/webhooks). Your plan must include the API.
>
> **2. Save your URL**
>
> Enter your HTTPS endpoint, for example `https://example.com/webhooks/followr`.
>
> **3. Copy the secret**
>
> Followr creates it when you first save a URL. Copy it from **Webhook Secret** to [verify requests](https://docs.followr.ai/webhooks/verify-signatures.md).

> [tab] With the API
>
> Send `webhook_posts_url` in `PUT /companies/{id}`. The response has the `webhook_secret`.
>
> ```bash cURL theme={null}
> curl --request PUT https://api.followr.ai/api/companies/1287 \
>   --header "Authorization: Bearer $FOLLOWR_API_KEY" \
>   --header "Accept: application/json" \
>   --header "Content-Type: application/json" \
>   --data '{"webhook_posts_url": "https://example.com/webhooks/followr"}'
> ```
>
> ```python Python theme={null}
> import os
> import requests
>
> response = requests.put(
>     "https://api.followr.ai/api/companies/1287",
>     headers={
>         "Authorization": f"Bearer {os.environ['FOLLOWR_API_KEY']}",
>         "Accept": "application/json",
>     },
>     json={"webhook_posts_url": "https://example.com/webhooks/followr"},
>     timeout=30,
> )
> response.raise_for_status()
> print(response.json()["data"]["webhook_secret"])
> ```
>
> ```javascript JavaScript theme={null}
> const response = await fetch("https://api.followr.ai/api/companies/1287", {
>   method: "PUT",
>   headers: {
>     Authorization: `Bearer ${process.env.FOLLOWR_API_KEY}`,
>     Accept: "application/json",
>     "Content-Type": "application/json",
>   },
>   body: JSON.stringify({ webhook_posts_url: "https://example.com/webhooks/followr" }),
> });
>
> if (!response.ok) {
>   throw new Error(`Followr API error ${response.status}: ${await response.text()}`);
> }
>
> const { data } = await response.json();
> console.log(data.webhook_secret);
> ```
>
> ```php PHP theme={null}
> <?php
>
> $ch = curl_init('https://api.followr.ai/api/companies/1287');
> curl_setopt_array($ch, [
>     CURLOPT_CUSTOMREQUEST => 'PUT',
>     CURLOPT_RETURNTRANSFER => true,
>     CURLOPT_HTTPHEADER => [
>         'Authorization: Bearer ' . getenv('FOLLOWR_API_KEY'),
>         'Accept: application/json',
>         'Content-Type: application/json',
>     ],
>     CURLOPT_POSTFIELDS => json_encode(['webhook_posts_url' => 'https://example.com/webhooks/followr']),
> ]);
>
> $body = curl_exec($ch);
> $status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
> curl_close($ch);
>
> if ($status !== 200) {
>     throw new RuntimeException("Followr API error {$status}: {$body}");
> }
>
> echo json_decode($body, true)['data']['webhook_secret'], PHP_EOL;
> ```
>
> > [!NOTE]
> >
> > Use `PUT`, even for a new company. A URL sent in `POST /companies` gets no secret, so its requests arrive with an empty `X-Company-Secret`.

To stop, select **Remove** in the app or send `"webhook_posts_url": null`. The company keeps its secret for the next URL.

## The request

Headers: `Content-Type: application/json` and `X-Company-Secret`, the company's secret ([check it](https://docs.followr.ai/webhooks/verify-signatures.md) on every request). The body is the post as it is when the request is sent:

```json theme={null}
{
  "id": 240551,
  "social_network_type": "instagram",
  "title": null,
  "description": "Our winter blend is here. Come taste it this weekend.",
  "status": "published",
  "status_message": null,
  "media_fetch_failures": null,
  "external_id": "17912345678901234",
  "link": null,
  "preferences": { "media_product_type": "FEED" },
  "created_at": "2026-12-10T16:20:05.000000Z",
  "updated_at": "2026-12-15T09:30:42.000000Z",
  "published_at": "2026-12-15T09:30:41.000000Z"
}
```

There is no event name, company ID or post group ID. With one URL for several companies, the secret tells you which one.

## Respond fast

| | |
| - | - |
| **Answer** | Any `2xx` once the secret checks out, then do the work. Followr ignores your response body. |
| **Timeout** | 10 seconds to connect, 30 seconds to answer. |
| **Retries** | None: one attempt per change. If your endpoint is down, slow or returns an error, that change isn't sent again. |
| **Failures** | The webhook is never turned off. The next change is sent as usual. |
| **Redirects** | Avoid them: a redirected `POST` can arrive as a `GET` with no body. |

> [!NOTE]
>
> Don't rely on webhooks alone. If a post's request never arrives, read it with `GET /posts/{id}`.

## Ordering and duplicates

Requests are sent in the background, and the body is built at send time. So requests can arrive out of order, show a later status than the change that triggered them, or repeat a body.

Store the last `updated_at` you handled per post and ignore older ones. Use `id` + `status` + `updated_at` to skip changes you already processed.

## Test your webhook

**1. Use a test company**

Connect a test social account to a test company, so a real brand's secret stays private.

**2. Receive the requests**

Point its webhook at a request inspector (a request bin URL) or at your local server through a tunnel such as ngrok.

**3. Trigger a change**

Publish a post now, or schedule one a few minutes ahead.

To test without publishing, send your handler the example above with this [ready-made command](https://docs.followr.ai/webhooks/verify-signatures.md#test-your-endpoint).

> [!WARNING]
>
> Anyone with a public inspector's URL sees the secret, and a secret can't be changed. Only use one with a test company.

## Security

* The secret is 32 letters and digits, unique to the company.
* It travels in a header on every request: use an `https://` URL and don't log headers.
* You can't rotate it. Saving the URL again keeps the same secret. If it leaks, [contact support](https://docs.followr.ai/support.md).
* Every member of the company can read the secret, whatever their role. Keep the company's team list current.

> [card] [Webhook events](https://docs.followr.ai/webhooks/events.md)
>
> Every status and payload field.

> [card] [Verify webhook requests](https://docs.followr.ai/webhooks/verify-signatures.md)
>
> Check the secret in Node.js, Python and PHP.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.