# REST API (/growsocmed/docs/developers)

Authentication, workspaces, request and response conventions of the GrowSocmed REST API.

The REST API does everything the dashboard does with posts, media, ideas, comments, DMs, automations, statistics, short links and webhooks. Every endpoint is listed in the [API Reference](/growsocmed/docs/api-reference).

REST and MCP access are part of the paid plans; on the Free plan requests are refused with `403 plan_required`.

## Base URL [#base-url]

```txt
https://socmed.growpaces.com/api/v1
```

The OpenAPI document of the API is served at `/api/v1/openapi.json`.

## Authentication [#authentication]

Send a credential as a bearer token:

```bash
curl https://socmed.growpaces.com/api/v1/accounts \
  -H "Authorization: Bearer gs_..."
```

Two kinds of credentials work:

| Credential | Made in | Lifetime |
| --- | --- | --- |
| API key (`gs_…`) | Dashboard → **Developer** → **API keys**. The key is shown once. | Until you delete it. It keeps working after you sign out. |
| OAuth access token | An app you allow through the OAuth sign-in (MCP clients do this). | One hour, renewed with its refresh token; the grant ends when you sign out of GrowPaces, and at the latest 90 days after you allowed it. |

An API key has a scope: **write** (read and change, the default) or **read** (only `GET` requests; anything else is refused with `403 forbidden`). An OAuth grant carries the scopes you allowed.

## Workspaces [#workspaces]

Everything belongs to a workspace (accounts, posts, media…). Which one a request works in:

- **An API key bound to a workspace** (chosen when creating it) always works there.
- **An API key for all your workspaces** works in the workspace named by the `X-Workspace` header, or in your oldest workspace when the header is missing.
- **An OAuth token** works in the one workspace picked when you allowed the app.

```bash
curl https://socmed.growpaces.com/api/v1/posts \
  -H "Authorization: Bearer gs_..." \
  -H "X-Workspace: 3f1c…"
```

A bound key or a token refuses an `X-Workspace` of another workspace with `403 forbidden`. List your workspaces and their ids with [`GET /workspaces`](/growsocmed/docs/api-reference/me/list-workspaces). The MCP server also accepts `X-Workspace: *`, see [MCP](/growsocmed/docs/developers/mcp).

Members who are not owners or admins of a workspace only reach the features they were given: viewing needs at least view access, changing needs manage access, otherwise `403 forbidden` with `details.feature`.

## Requests and responses [#requests-and-responses]

- JSON bodies with `Content-Type: application/json`; field names in `snake_case`.
- Times in ISO 8601. Times you send for scheduling need an offset, like `2026-12-01T09:00:00+07:00`; times the API returns are UTC.
- Ids are UUIDs.
- Successful changes appear in the workspace's activity log, with the API or MCP as their source.

## Idempotency [#idempotency]

[`POST /posts`](/growsocmed/docs/api-reference/posts/create-post) takes an `Idempotency-Key` header (up to 200 characters). Sending the same key again in the same workspace creates nothing new: the response is the post made the first time, with `replayed: true`. Use one key per post you mean to create, for example the id of the row in your own system.

```bash
curl -X POST https://socmed.growpaces.com/api/v1/posts \
  -H "Authorization: Bearer gs_..." \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-1042" \
  -d '{"text":"New stock is in","targets":[{"account_id":"…"}]}'
```

## Pagination [#pagination]

Lists that can grow long return a page and a cursor:

```json
{ "data": [ … ], "next_cursor": "MjAyNi0xMS0yMFQwMjowMDowMC4wMDBafDAx…" }
```

Pass `next_cursor` back as `cursor` for the next page; `null` means there are no more. `limit` sets the page size (at most 100). [`GET /posts`](/growsocmed/docs/api-reference/posts/list-posts) and [`GET /comments`](/growsocmed/docs/api-reference/comments/list-comments) work this way. [`GET /media`](/growsocmed/docs/api-reference/media/list-media) takes the cursor as `before`. Cursors are opaque: do not build them yourself.

## Rate limits and errors [#rate-limits-and-errors]

All your API keys and MCP connections share one budget per minute; see [Rate limits](/growsocmed/docs/developers/rate-limits). Errors always have the same shape with a stable `code`:

```json
{ "error": { "code": "validation_failed", "message": "Some accounts cannot take this post", "details": { … } } }
```

See [Errors](/growsocmed/docs/developers/errors) for the codes.