# Automated Content Sharing

Use Firstup webhooks to notify your integration when content is published or archived. Your integration can then retrieve content details and create, update, or remove a corresponding post in an external system, such as Slack, SharePoint, or a CMS.

Your integration is responsible for publishing to the destination system and maintaining the relationship between the Firstup post and its external copy.

## Before You Start

You need:

* A publicly accessible HTTPS endpoint that can receive webhook POST requests.
* A Firstup API access token with the appropriate scopes.
* API access and publishing permissions for your destination system.
* A way to store the relationship between a Firstup content ID and the corresponding destination record ID.


Choose which content your integration should share and confirm that the destination’s access permissions are appropriate for that content.

### Required Scopes

| Scope | Purpose |
|  --- | --- |
| `webhooks.write` | Create, update, or delete webhook subscriptions. |
| `webhooks.read` | View subscriptions and send a test ping. |
| `content.read` | Retrieve content details from Firstup. |


### API Base URL

Use the API base URL for your Firstup region. Replace <API_BASE_URL> in the examples with the appropriate value.

| Region | API Base URL |
|  --- | --- |
| US1 | https://partner.socialchorus.com |
| US2 | https://partner.us2.onfirstup.com |
| EU | https://partner.onfirstup.eu |


### Event Triggers

| Event Name | When it Occurs | Integration Action |
|  --- | --- | --- |
| `content_published` | A content post is published to one or more topics. | Retrieve the post and create or update its external copy. |
| `content_archived` | A content post is archived, regardless of its previous state. | Deactivate, unpublish, or remove its external copy, as appropriate for the destination. |


Archiving, unpublishing, and deleting content are separate actions. If your integration must also reflect content edits, unpublishing, or deletion, consider subscribing to content_updated, content_unpublished, and content_deleted.

See [Webhook Events](/webhooks/webhook-events) for event descriptions and example event data.

## Creating a Webhook Subscription

### Step 1: Create a subscription

Register your receiver URL and subscribe to both publication and archiving events.

```
POST <API_BASE_URL>/v2/webhooks/subscriptions
Authorization: Bearer <ACCESS_TOKEN>
Content-Type: application/json
```

```
{
  "url": "https://example.com/webhooks/firstup",
  "authorization_header": "Bearer <RECEIVER_SECRET>",
  "active": true,
  "events": [
    {
      "name": "content_published",
      "version": "1"
    },
    {
      "name": "content_archived",
      "version": "1"
    }
  ]
}
```

A successful request returns 201 Created. Save the subscription ID returned in the response so you can test, update, or delete the subscription later.

Firstup sends an automatic ping when a subscription is created. Make sure your receiver is ready to accept requests before registering it.

#### Subscription Attributes

| Attribute | Description |
|  --- | --- |
| `url` | The HTTPS endpoint that receives webhook deliveries. |
| `authorization_header` | An optional value Firstup sends in the Authorization header of delivery requests. Configure your receiver to validate this value. |
| `active` | Whether the subscription sends event deliveries. Inactive subscriptions can still receive test pings. |
| `events` | The event names and versions the subscription receives. |


The Firstup API access token and receiver secret serve different purposes. The access token authorizes requests to Firstup. The receiver secret lets your endpoint authenticate incoming webhook deliveries.

### Step 2: Receive and Validate Deliveries

Configure your receiver to:

1. Validate the incoming Authorization header against your configured receiver secret.
2. Accept the delivery and store or queue it for processing.
3. Return a successful 2xx response promptly.
4. Process each event included in the delivery.


Deliveries can contain multiple events. Handle each event individually and support test events named ping.

Use the `X-SocialChorus-Delivery` header to identify deliveries in your logs. Design processing to handle duplicate deliveries without creating duplicate posts.

See [Webhooks Overview](/webhooks/webhooks-overview) for delivery details and retry behavior.

### Step 3: Handle Published Content

When you receive a `content_published` event:

1. Read the event’s content_id and channel_ids.
2. Apply your integration’s topic-selection rules.
3. Retrieve the content details.
4. Create or update the corresponding post in the destination system.
5. Save the destination record ID alongside the Firstup content ID.


In the API, topics are represented as channels. Use `channel_ids` to identify the topics associated with the publication event. The subscription request does not include a topic-filter setting.

#### Retrieve Content Details

```
GET <API_BASE_URL>/v2/content/{content_id}
Authorization: Bearer <ACCESS_TOKEN>
```

Use the returned content fields to build the destination post. Depending on your requirements, these might include its title, body, summary, images, and permalink.

See [Fetch the details of a content post](/endpoints/openapi/content-publishing/detailcontent) for the response schema.

If retrieval fails, record the failure and handle it before attempting to publish externally.

### Step 4: Handle Archived Content

When you receive a `content_archived` event:

1. Read the event’s content_id.
2. Look up the corresponding destination record.
3. Deactivate, unpublish, or remove that record according to your integration’s rules.
4. Update your stored mapping to reflect the result.


Use the stored destination record ID to identify the external copy. If your integration did not previously share the Firstup post, no destination action is required.

### Step 5: Test the Integration

#### Send a Test Ping

Use the saved subscription ID to send a test delivery:

```
POST <API_BASE_URL>/v2/webhooks/subscriptions/{subscription_id}/ping
Authorization: Bearer <ACCESS_TOKEN>
```

Inspect `data.delivery.status` in the response. A value of success indicates that Firstup recorded a successful delivery response.

A successful ping verifies delivery to your receiver. Test content retrieval and external publishing separately.

#### Test the Complete Workflow

Using controlled test content:

1. Publish a post to a topic selected by your integration.
2. Confirm that your receiver processes the publication event.
3. Verify that the expected external post is created and its destination ID is stored.
4. Archive the Firstup post.
5. Confirm that your integration updates or removes the external copy.
6. Test duplicate-delivery handling to verify that processing does not create duplicate posts.


#### Manage the Subscription

You can update, disable, or delete the subscription as your integration changes.

| Action | Endpoint |
|  --- | --- |
| View a subscription | GET /v2/webhooks/subscriptions/{subscription_id} |
| Update or disable a subscription | PUT /v2/webhooks/subscriptions/{subscription_id} |
| Delete a subscription | DELETE /v2/webhooks/subscriptions/{subscription_id} |


To disable event deliveries, update the subscription with "active": false.

When updating events, send the complete list of events you want the subscription to receive. The array replaces the existing event list.

See the [Webhooks API reference](/endpoints/openapi/webhooks) for request and response details.