---
title: "Create a federation subscription"
method: POST
path: "/api/federation/subscriptions"
tags: ["Federation"]
---

# Create a federation subscription

`POST /api/federation/subscriptions`

## Request

- Base URL: `http://localhost:38200`
- URL: `http://localhost:38200/api/federation/subscriptions`
- Auth: one of:
  - HTTP bearer
  - API key in cookie `token`

Provisions a dedicated shadow workspace for this subscription and returns the webhook secret **only this once**. `sourceInstanceUrl` must be `https://` by default (T602) — the subscriber's real bearer API key is sent to it on every scheduled pull.

## Request body

- object
  - `name` string, required
  - `sourceInstanceUrl` string, required
  - `remoteWorkspace` string
  - `apiKey` string, required: Plaintext API key issued by the remote instance's operator. Encrypted at rest.
  - `pollIntervalMinutes` integer

## Response `201`

Created subscription plus the webhook secret (shown once).

- FederationSubscription: Never includes the encrypted API key. `webhookSecret` is `null` except on the responses that explicitly reveal it once (create, rotate-webhook-secret).
  - `id` integer
  - `tenantId` integer
  - `name` string
  - `sourceInstanceUrl` string
  - `remoteWorkspace` string
  - `shadowWorkspaceId` integer
  - `signingKeyId` string, nullable
  - `signingPubkey` string, nullable
  - `cursor` string, date-time, nullable
  - `pollIntervalMinutes` integer
  - `status` 'active' | 'paused' | 'revoked'
  - `webhookSecret` string, nullable
  - `lastSyncedAt` string, date-time, nullable
  - `lastSyncStatus` string, nullable
  - `lastSyncError` string, nullable
  - `lastSyncStats` object, nullable
  - `createdByUserId` integer, nullable
  - `createdAt` string, date-time
  - `updatedAt` string, date-time

## Other responses

- `400`: Validation failure, invalid/insecure sourceInstanceUrl, or invalid input.
- `401`: Missing or invalid credentials.
- `403`: The caller has no resolvable tenant context.

---

[API](https://skmtc.dev/contextq/apis/contextq-api.md) · [All operations](https://skmtc.dev/contextq/apis/contextq-api/llms.txt) · [OpenAPI document](https://skmtc.dev/contextq/apis/contextq-api/revisions/7afc44056a22?raw)
