# Quickstart: your first post with the APIWings API

> From an API key to your first post with the APIWings social media API in five steps - profile, hosted account connection, media, POST /v1/posts with an idempotency key, and signed webhooks.

- Canonical URL: https://apiwings.com/docs/quickstart
- Updated: 2026-11-23
- Publisher: APIWings

From zero to your first post in five steps. The API is in private beta: API keys are given to beta teams ([ask for access](https://apiwings.com/#waitlist)). The current API runs at `https://api-staging.apiwings.com`; its OpenAPI spec is at [/v1/openapi.json](https://api-staging.apiwings.com/v1/openapi.json).

```bash
export APIWINGS_API_KEY=aw_test_...
export APIWINGS_BASE_URL=https://api-staging.apiwings.com
```

Every request takes the key as a bearer token: `Authorization: Bearer $APIWINGS_API_KEY`. Keys start with `aw_live_` or `aw_test_`. Keep them in an environment variable or a secrets manager: never in a repository, a chat or front-end code.

## 1. Create a profile

A profile is one end customer of your product. Their connected accounts and posts are kept apart from everyone else's.

```bash
curl -s $APIWINGS_BASE_URL/v1/profiles \
  -H "Authorization: Bearer $APIWINGS_API_KEY" -H "Content-Type: application/json" \
  -d '{"name": "Acme", "external_id": "customer-42"}'
# 201 → {"id": "<profile_id>", "external_id": "customer-42", "name": "Acme", "created_at": "…"}
```

`external_id` is your own identifier for that customer (optional). A key scoped to one profile cannot create profiles (`403`).

## 2. Connect an account

Ask for a hosted connect link and send your user to it. They sign in on the network's own consent screen (for Bluesky, a form where they enter an app password), and come back to your `redirect_url`.

```bash
curl -s -X POST $APIWINGS_BASE_URL/v1/profiles/<profile_id>/connect/bluesky \
  -H "Authorization: Bearer $APIWINGS_API_KEY" -H "Content-Type: application/json" \
  -d '{"redirect_url": "https://your-app.example.com/connected"}'
# 200 → {"connect_url": "https://…/connect/…", "account_id": null, "expires_at": "…"}
```

- The link is valid for 15 minutes and works once.
- On success the user returns to `redirect_url?status=connected&account_id=…&account_ids=…&platform=…`. One consent can grant several accounts (for example several Facebook Pages): `account_ids` lists them all and `account_id` is the first.
- On failure: `redirect_url?status=error&code=…`.
- `redirect_url` must be https (http only for `localhost`).
- List a profile's accounts with `GET /v1/profiles/<profile_id>/accounts`; disconnect one with `DELETE /v1/accounts/<account_id>` (its tokens are destroyed).

Bluesky can also be connected without the hosted page, by sending the handle and an app password in the body: `{"bluesky": {"identifier": "yourname.bsky.social", "app_password": "…"}}`. The response then has `account_id` and `connect_url: null`. Only do this when the user typed the app password into your own product; never ask for it in a chat or an email.

**Your brand on the connect pages:** `POST /v1/branding` with `name`, `logo_url` (https) and `color` (`#RRGGBB`) shows your name and logo instead of APIWings on the hosted pages.

## 3. Add media

Two ways, which you can mix (up to 10 files per post):

**By URL.** Put public https URLs in `media_urls`. APIWings checks each one when the post is created (type and size) and downloads it before publishing. JPEG, PNG, WebP, GIF, MP4 and MOV, up to 1 GB.

**By upload.** Ask for an upload URL, then `PUT` the file to it with the same `Content-Type`:

```bash
curl -s $APIWINGS_BASE_URL/v1/media \
  -H "Authorization: Bearer $APIWINGS_API_KEY" -H "Content-Type: application/json" \
  -d '{"mime": "image/jpeg", "bytes": 482113}'
# 201 → {"id": "<media_id>", "upload_url": "https://…", "upload_method": "PUT", "expires_in": 900, "expires_at": "…"}

curl -s -X PUT "<upload_url>" -H "Content-Type: image/jpeg" --data-binary @photo.jpg
```

The upload URL is valid for 15 minutes; the file is kept for 7 days. Use its `id` in `media`. Each network accepts only some formats and sizes: check its page before you upload.

## 4. Publish

```bash
curl -s $APIWINGS_BASE_URL/v1/posts \
  -H "Authorization: Bearer $APIWINGS_API_KEY" -H "Content-Type: application/json" \
  -d '{
    "profile_id": "<profile_id>",
    "content": "Hello from APIWings",
    "media": ["<media_id>"],
    "platforms": [{"platform": "bluesky", "options": {"alt": "Our team at the office"}}],
    "idempotency_key": "post-2026-11-23-001"
  }'
# 202 → {"id": "<post_id>", "status": "queued", "platforms": [{"platform": "bluesky", "status": "pending", …}], …}
```

- `idempotency_key` is required (8 to 128 characters). Sending the same key again returns the existing post with `200` and never publishes twice, so you can retry safely after a timeout.
- `account_id` is only needed when the profile has more than one active account of that network.
- `options` are per network and validated by that network: see each [network page](https://apiwings.com/docs).
- To schedule, add `"scheduled_at": "2026-12-01T10:00:00Z"`. Cancel a scheduled post that has not started publishing with `DELETE /v1/posts/<post_id>` (`409` if it already started).

Then read the result:

```bash
curl -s $APIWINGS_BASE_URL/v1/posts/<post_id> -H "Authorization: Bearer $APIWINGS_API_KEY"
```

Each entry of `platforms` has `status` (`pending`, `publishing`, `published`, `failed`, `canceled`), `remote_id`, `url`, `visibility`, `error`, `published_at` and, for networks that charge per post, `platform_cost_usd`. `visibility` is the one the network actually applied (`public`, `private`, `unlisted`, `self_only` or `draft`), never assumed.

Some networks need extra endpoints:

- `GET /v1/accounts/<account_id>/publish-options`: live data your posting screen must show before publishing (TikTok's creator info). See [TikTok](https://apiwings.com/docs/tiktok).
- `GET /v1/accounts/<account_id>/limits`: how many posts the account can still publish, live from the network when it says (Instagram, Threads), or a note on how it is limited.

## 5. Get webhooks

```bash
curl -s $APIWINGS_BASE_URL/v1/webhooks \
  -H "Authorization: Bearer $APIWINGS_API_KEY" -H "Content-Type: application/json" \
  -d '{"url": "https://your-app.example.com/hooks/apiwings",
       "events": ["post.published", "post.failed", "account.disconnected", "account.expiring"]}'
# 201 → {…, "secret": "…"}   (the secret is shown only once)
```

| Event | When | `data` |
|---|---|---|
| `post.published` | A target was published | `post_id`, `profile_id`, `platform`, `account_id`, `remote_id`, `url`, `visibility` |
| `post.failed` | A target failed for good (after retries) | `post_id`, `profile_id`, `platform`, `account_id`, `error` |
| `account.disconnected` | An account can no longer publish (token revoked or expired, disconnected through the API or from the network) | `account_id`, `profile_id`, `platform`, `reason` |
| `account.expiring` | A connection that cannot renew itself expires soon (sent once, up to 7 days before), for example on LinkedIn | `account_id`, `profile_id`, `platform`, `expires_at`, `reason` |

The body is `{"event": "…", "created_at": "…", "data": {…}}`. Each delivery carries `X-APIWings-Signature: t=<unix ms>,v1=<hex HMAC-SHA256 of "<t>.<raw body>" with your secret>`. Verify it on the raw body and reject deliveries older than 5 minutes:

```js
import { createHmac, timingSafeEqual } from "node:crypto";

export function verifyApiWings(secret, header, rawBody) {
  const parts = Object.fromEntries(header.split(",").map((p) => p.split("=")));
  const t = Number(parts.t);
  if (!t || Math.abs(Date.now() - t) > 5 * 60_000) return false;
  const expected = createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex");
  const got = parts.v1 ?? "";
  return got.length === expected.length && timingSafeEqual(Buffer.from(got), Buffer.from(expected));
}
```

Answer with a `2xx` within 10 seconds. A failed delivery is retried twice (after 2 and then 8 seconds); a `4xx` answer other than `408` or `429` is not retried.

## Errors

Every error is JSON `{code, error, platform_message?}` with an `X-Request-Id` header (include it when you contact support). The codes and what to do with each are on the [docs overview](https://apiwings.com/docs#errors). A resource of another customer always answers `404`.

## SDKs, CLI and MCP

Available to beta teams, published before the public launch:

- **TypeScript SDK**: a typed client generated from the OpenAPI spec, with no dependencies.
- **Python SDK**: standard library only, including webhook signature verification.
- **CLI**: `apiwings post "Hello" --to bluesky --media-url https://cdn.example.com/photo.jpg --json`, with JSON output for scripts and AI agents.
- **MCP server** for AI agents (Claude, Cursor and any MCP client), with the tools `connect`, `upload_media`, `create_post`, `get_post` and `list_accounts`. The API key goes in the server's environment, never in the conversation.

Any AI agent or automation tool that can call an HTTP API can also load the [OpenAPI spec](https://api-staging.apiwings.com/v1/openapi.json) directly.
