# Partner onboarding: connect a client's accounts
URL: https://skedcast.com/developers/partner-onboarding

If you run your own product on top of SkedCast — an agency tool, a creator platform, a vertical SaaS — you can onboard a customer end to end without them ever seeing a SkedCast login. Create a client, mint a connect link, let the customer authorize their own accounts, and publish through the API. This is the exact flow, start to finish.

## The flow at a glance
Four steps, all over the REST API with your own API key (or an OAuth token). The customer's only touch point is the connect link — they never create a SkedCast account.
- Create a client for the customer (`clients.manage`).
- Mint a connect link scoped to the platforms you need (`accounts.connect`).
- The customer opens the link and authorizes their own accounts — no SkedCast login.
- Post on their behalf via the API (`posts.compose`), targeting the now-connected accounts.

## Scopes you'll need
This flow uses `clients.manage` (create the client), `accounts.connect` (mint the link), `accounts.read` (see what connected), and `posts.compose` (publish). All are Owner/Manager actions — a key's effective power is still scopes ∩ role.

## 1. Create the client
Each customer becomes a client group in your workspace. Create is idempotent on `(agency, name)`, so a retried request never duplicates. Keep the returned `id` — every later step is scoped to it.

## Create the customer's client.
```bash
curl -X POST https://api.skedcast.com/v1/clients \
  -H "Authorization: Bearer sked_live_YOUR_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Riverside Coffee Co.", "type": "brand" }'
```

## 2. Mint a connect link
Mint a link bound to that client, listing the platforms the customer should connect. The link is valid until `expiresAt` (`expiresInHours`, 1–168, default 48) and is multi-use within that window — one link connects every requested platform.

## Mint the connect link.
```bash
curl -X POST https://api.skedcast.com/v1/clients/<clientId>/connect-invites \
  -H "Authorization: Bearer sked_live_YOUR_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{ "platforms": ["instagram", "tiktok"], "expiresInHours": 72 }'
```

## Response — hand data.url to the customer.
```json
{
  "data": {
    "inviteId": "3f9a…",
    "url": "https://app.skedcast.com/invite/inv_9f3a2b…",
    "token": "inv_9f3a2b…",
    "platformsRequested": ["instagram", "tiktok"],
    "expiresAt": "2026-07-06T15:00:00Z"
  },
  "meta": { "correlationId": "c-…" }
}
```

## 3. The customer connects — no SkedCast login
Send the customer the `url`. They open it in a browser, see your agency + their client name and the platforms you requested, and connect each one through the platform's own OAuth — all without a SkedCast account. Already-connected platforms show a checkmark, so a re-sent link only asks for what's missing.
Because the link is multi-use within its TTL, the customer can connect Instagram now and come back for TikTok later from the same link.

## 4. Post on their behalf
Once accounts are connected, confirm them with `GET /accounts?clientId=<clientId>` and compose a post targeting them — exactly like the quickstart, just scoped to this client. The `posts.compose` scope publishes; each mutation carries an `Idempotency-Key`.

## List the client's connected accounts, then publish.
```bash
# see what connected
curl "https://api.skedcast.com/v1/accounts?clientId=<clientId>" \
  -H "Authorization: Bearer sked_live_YOUR_KEY"

# publish on their behalf
curl -X POST https://api.skedcast.com/v1/posts \
  -H "Authorization: Bearer sked_live_YOUR_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{ "clientId": "<clientId>", "content": "New drop is live 🚗", "targets": { "mode": "selection", "accountIds": ["<accountId>"] }, "schedule": { "type": "at", "scheduledAt": "2026-07-08T15:00:00Z" } }'
```

## Reconnecting on day N
Tokens expire and platforms disconnect. When that happens, just mint a fresh connect link for the same client and send it again — there is no long-lived link to rotate, and the customer's still-connected platforms show as connected on the page. See the API reference's Connect links section for the full semantics.

## FAQ
**Q: Does the customer need a SkedCast account?**
A: No. The connect link is the whole interface — they open it, authorize their own accounts through each platform's OAuth, and never create or see a SkedCast login. You manage everything else via the API.

**Q: Can one link connect several platforms?**
A: Yes. List every platform in `platforms` when you mint the link. The link is multi-use within its TTL, so the customer can connect one platform now and return for the others later from the same URL.

**Q: What happens when a connection expires later?**
A: Mint a new connect link for the same client and re-send it. Links are cheap and disposable; already-connected platforms show as connected, so a day-N link only asks for what's missing.
