> ## Documentation Index
> Fetch the complete documentation index at: https://docs.postsyncer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Import the API into Postman or a code generator

> One OpenAPI file describes all of API v1. Import it into Postman or Insomnia, or generate a client from it.

The whole of API v1 is described in one OpenAPI file:

```text theme={null}
https://docs.postsyncer.com/api-reference/openapi.json
```

The [API reference](https://docs.postsyncer.com/api-reference/introduction.md) on this site is made from the same file, so the two say the same thing. On any reference page, **Download API spec** in the menu at the top of the page downloads it.

## What's in the file

* OpenAPI 3.0.3, with the server `https://postsyncer.com/api/v1`. The upload endpoint names its own server, the upload host (below).
* Bearer authentication, `bearerAuth`: send your key as `Authorization: Bearer YOUR_API_KEY`.
* Every endpoint, each with an `operationId` such as `listPosts` or `createPost`, and one tag for its group, such as `Posts` or `Media`.
* `x-permission` on each endpoint: the key permission it needs, such as `posts:read`. An endpoint that can schedule or publish lists those permissions too.
* Request and response examples, with made-up data, and a schema for each object.

One endpoint is on another host. `POST /media/upload/file` (`uploadMediaFile`) goes to `https://upload.postsyncer.com/api/v1`, with the same key, and the file names that host on the endpoint. Some tools ignore a server set on one endpoint and send every request to the main address: check the upload request's address after you import.

> [!WARNING]
>
> Requests from Postman, Insomnia or a generated client act on your real account. Try them with a draft-only key: see [Test safely](https://docs.postsyncer.com/test-safely.md).

## Import into Postman

1. In Postman, click **Import**.
2. Paste `https://docs.postsyncer.com/api-reference/openapi.json` and choose to import it as a **Postman Collection**.
3. Open the new collection's **Authorization** tab, choose **Bearer Token**, and put in your key. Store it in a variable or a vault secret rather than in the collection, so it isn't shared with it.
4. Check the upload request's address. If it isn't `https://upload.postsyncer.com/api/v1/media/upload/file`, change it to that.

Postman makes a request for each endpoint, with the examples from the file. To pick up new endpoints later, import the file again.

## Import into Insomnia

1. In Insomnia, choose **Import**.
2. Paste the URL, or pick the file if you downloaded it.
3. Set Bearer authentication with your key on the requests, and check the upload request's address, as in Postman.

## Generate a client

Any OpenAPI 3.0 generator reads the file. This example makes a TypeScript client with [OpenAPI Generator](https://openapi-generator.tech), which needs Java:

```bash theme={null}
npx @openapitools/openapi-generator-cli generate \
  -i https://docs.postsyncer.com/api-reference/openapi.json \
  -g typescript-fetch \
  -o ./postsyncer-client
```

The generator makes one class for each tag (`PostsApi`, `MediaApi`, `WorkspacesApi`…) and names each method after its `operationId`. List your workspaces:

```typescript theme={null}
import { Configuration, WorkspacesApi } from "./postsyncer-client";

const config = new Configuration({
  basePath: "https://postsyncer.com/api/v1",
  accessToken: "YOUR_API_KEY",
});

const workspaces = await new WorkspacesApi(config).listWorkspaces();
console.log(workspaces.map((workspace) => workspace.name));
```

If the generated `uploadMediaFile` calls the main address, your generator ignored the endpoint's server. Then make a second `Configuration` with `basePath: "https://upload.postsyncer.com/api/v1"` and call `uploadMediaFile` through a `MediaApi` made with it.

Generate the client again when the API changes. The [changelog](https://docs.postsyncer.com/changelog.md) says what changed, and [versioning](https://docs.postsyncer.com/versioning.md) says what we add without notice: new fields, endpoints and values. Write your code so a field or value it doesn't know doesn't break it.

## Related

> [card] [API reference](https://docs.postsyncer.com/api-reference/introduction.md)
>
> Every endpoint, with a playground to try it.

> [card] [CLI](https://docs.postsyncer.com/tools/cli.md)
>
> Send the same requests from a terminal.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.