---
title: "Exchange Mastodon OOB authorization code"
method: POST
path: "/accounts/mastodon/exchange"
tags: ["Accounts"]
---

# Exchange Mastodon OOB authorization code

`POST /accounts/mastodon/exchange`

## Request

- Base URL: `https://app.openpo.st/api/v1`
- URL: `https://app.openpo.st/api/v1/accounts/mastodon/exchange`
- Auth: one of:
  - HTTP bearer
  - API key in cookie `openpost_session`

## Request body

- ExchangeCodeInputBody
  - `$schema` string, uri: A URL to the JSON Schema for this object.
  - `code` string, required: Authorization code from OAuth flow
  - `instance_url` string, required: Mastodon instance URL to dynamically register
  - `intent` 'production' | 'certification_test': Typed execution intent; certification_test requires an unscoped instance administrator
  - `server_name` string, required: Mastodon server name from config
  - `workspace_id` string, required: Workspace ID

## Response `200`

OK

- AccountConnectionResponse
  - `$schema` string, uri: A URL to the JSON Schema for this object.
  - `account_id` string, required: OpenPost destination account ID
  - `account_ids` string[], nullable, required: All connected OpenPost account IDs
  - `open_fresh_composer` boolean, required: Whether this is the Workspace's first connected destination
  - `workspace_id` string, required: Workspace receiving the connected destination

## Other responses

- `400`: Bad Request
- `422`: Unprocessable Entity
- `500`: Internal Server Error

---

[API](https://skmtc.dev/openpo/apis/openpost-api.md) · [All operations](https://skmtc.dev/openpo/apis/openpost-api/llms.txt) · [OpenAPI document](https://skmtc.dev/openpo/apis/openpost-api/revisions/67d3964458a7?raw)
