# Embedding Indrava in your product

> For AI agents: the index of these docs is at https://indrava.forumulate.com/docs/llms.txt (every page it lists has a Markdown version like this one).

Give each of your customers their own Indrava workspace from your server, let them connect channels without an Indrava account, and post on their behalf.

Use the embedding API when your product wants social publishing for its own customers and you do not want them to sign up to Indrava. Your server creates one **tenant workspace** per customer. Each tenant is a full workspace of its own: its channels, posts and files are kept apart from every other tenant's and from yours.

Everything here is server to server. Never put a key in a browser or an app.

:::hint{style="warning" title="Not yet run on a hosted Indrava"}
The embedding API passes its automated checks, but it has not yet run against a hosted Indrava with real tenants. Treat it as a preview until this note is removed.
:::

## What you need

An API key of your own workspace with the scope `embed:write`. Create it under **Developers** in the app. This key manages tenants; it is not the key you post with.

## 1. Create a workspace for a customer

```sh
curl -X POST http://localhost:4000/api/v1/embed/tenants \
  -H "Authorization: Bearer $INDRAVA_PARTNER_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "externalId": "customer-42", "name": "Acme Bakery", "webhookUrl": "https://your.app/indrava/events" }'
```

```json
{
  "externalId": "customer-42",
  "name": "Acme Bakery",
  "organizationId": "org_…",
  "createdAt": "2027-01-04T09:00:00.000Z",
  "apiKey": "ak_…",
  "webhookSecret": "whsec_…"
}
```

- `externalId` is your own id for the customer (letters, digits, `.`, `:`, `-`, `_`). Every other tenant route takes it in the path, so you never have to store an Indrava id.
- `apiKey` is **the tenant's key**, shown once. Store it encrypted next to the customer. If it is lost or leaked, replace it with `POST /embed/tenants/{externalId}/key`: every earlier key of that tenant stops working.
- The call is idempotent: sending the same `externalId` again renames the workspace, puts it on your current plan, and returns `"apiKey": null`.
- `webhookUrl` is optional and read on the first call only. Every [event](https://indrava.forumulate.com/docs/events) of the tenant workspace is delivered there, signed with `webhookSecret`. Verify it as described in [Receive webhooks](https://indrava.forumulate.com/docs/webhooks).

## 2. Let the customer connect a channel

```sh
curl -X POST http://localhost:4000/api/v1/embed/tenants/customer-42/connect \
  -H "Authorization: Bearer $INDRAVA_PARTNER_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "provider": "linkedin", "redirectUrl": "https://your.app/settings/social" }'
```

```json
{ "url": "http://localhost:4000/connect/…", "expiresAt": "2027-01-04T10:00:00.000Z" }
```

Send the customer's browser to `url`. They see which workspace is asking, sign in at the platform, and return to your `redirectUrl` with the outcome in the query:

| Query | Meaning |
| --- | --- |
| `status=connected&channels=<id>,<id>` | The channels that were saved |
| `status=error&error=<message>` | Nothing was saved; the message can be shown to the customer |

Do not treat the query as proof: anyone can open your `redirectUrl` with a made-up query. Confirm with `GET /embed/tenants/{externalId}/channels` or the `channel.connected` event.

- The link works for one hour and for any number of sign-ins in that time.
- `provider` is an id from `GET /channels/providers`. Only platforms that connect by signing in can be used here. Platforms that take pasted credentials (an app password, a bot token) are connected with the tenant's key and `POST /channels/connect`.
- `redirectUrl` must be `https` (`http://localhost` is accepted while you develop). Without it the customer ends on a plain Indrava page that says the channel is connected.

## 3. Post on the customer's behalf

Use **the tenant's key** with the ordinary API. Nothing about these calls is special: the key decides which workspace they act on.

```sh
curl -X POST http://localhost:4000/api/v1/posts \
  -H "Authorization: Bearer $TENANT_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "parts": [{ "text": "Fresh sourdough at 8." }],
    "targets": [{ "channelId": "<channel id>" }],
    "action": "schedule",
    "scheduledAt": "2027-01-05T08:00:00Z"
  }'
```

The tenant's key holds every scope except the `embed` ones, so media, analytics, the inbox and the rest of the [operations](https://indrava.forumulate.com/docs/operations) work the same way.

## Manage tenants

| Call | What it does |
| --- | --- |
| `GET /embed/tenants` | Your tenants, newest first |
| `GET /embed/tenants/{externalId}/channels` | A tenant's channels, with their state |
| `DELETE /embed/tenants/{externalId}/channels/{channelId}` | Disconnect a channel (access is revoked at the platform) |
| `POST /embed/tenants/{externalId}/key` | Replace the tenant's key |
| `DELETE /embed/tenants/{externalId}` | Delete the workspace and everything in it. Not reversible |

## Plans and limits

- You can have as many tenants as your plan includes clients. Past that, creating another tenant answers `402` with the code `PLAN_LIMIT_REACHED`.
- A tenant workspace gets your plan's limits (channels, scheduled posts per month, AI credits) when it is created, and follows your plan when it changes: every tenant is moved within a few minutes, with no call from you. A tenant that Indrava gave limits of its own keeps them through your plan changes.
- [Rate limits](https://indrava.forumulate.com/docs/rate-limits) are counted per key, so one busy tenant does not slow the others.

## Security notes

- A tenant can only ever be reached through the partner workspace that created it: another partner sending the same `externalId` gets its own, separate workspace.
- Tenant keys cannot create tenants or read your own workspace.
- Deleting your own Indrava workspace does not delete its tenants. Delete them first.

---

## For AI agents

- This page for a human reader: https://indrava.forumulate.com/docs/embedding
- The whole space as one Markdown file: https://indrava.forumulate.com/docs/llms-full.txt
- Live search + fetch over MCP: https://indrava.forumulate.com/docs/_api/public/orgs/e421ace4-3e78-4ed8-9818-7b4899cf3aa0/spaces/2bcc7f09-4489-40af-85d8-9fdd3f3da314/mcp
  - Install (Claude CLI): `claude mcp add forumulate-docs --transport http https://indrava.forumulate.com/docs/_api/public/orgs/e421ace4-3e78-4ed8-9818-7b4899cf3aa0/spaces/2bcc7f09-4489-40af-85d8-9fdd3f3da314/mcp`

This Markdown is the same content the page renders — safe to quote and to ground answers in.
