# API introduction

> The Memberfy REST API: base address, format, headers and where to start integrating.

Everything the Memberfy interface does goes through a REST API, and it's open to you: you can automate your community, integrate it with other systems or build your own interface.

## The essentials

| | |
|---|---|
| **Address** | `https://api.memberfy.net` |
| **Format** | JSON, in UTF-8 |
| **Authentication** | A JWT token in the `Authorization: Bearer <token>` header. See [Authentication](/api/autenticacao) |
| **Community** | The `X-CommunityId` header on almost every call. See [X-CommunityId](/api/x-community-id) |
| **Responses** | Always in the `{ success, message, data }` envelope. See [Responses and errors](/api/respostas-e-erros) |
| **Lists** | `page` and `limit`. See [Pagination](/api/paginacao) |
| **Specification** | OpenAPI 3 at [`/docs.json`](https://api.memberfy.net/docs.json) |
| **SDK** | Ready-made JavaScript at [`/sdk.js`](https://api.memberfy.net/sdk.js). See [JavaScript SDK](/api/sdk-js) |

## The headers

| Header | When |
|---|---|
| `Authorization: Bearer <token>` | On everything except sign-in, sign-up and public routes |
| `X-CommunityId: <uuid>` | Almost always: sets which community the operation happens in |
| `X-ProfileId: <uuid>` | Optional: act on behalf of another profile, for those allowed to |
| `Accept-Language` | Optional: the language of the messages (`pt-BR`, `pt-PT`, `en-US`, `es-ES`, `es-MX`, `es-AR`, `it-IT`, `de-DE`, `de-AT`, `de-CH`). Default `pt-BR` |

## Your first call

```bash
# 1. sign in
curl -s -X POST https://api.memberfy.net/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email":"you@memberfy.net","password":"your-password"}'

# 2. with the token and the community id
curl -s https://api.memberfy.net/api/spaces \
  -H "Authorization: Bearer $TOKEN" \
  -H "X-CommunityId: $COMMUNITY_ID"
```

## Where to start

1. [Authentication](/api/autenticacao): the token.
2. [X-CommunityId](/api/x-community-id): the community of each call.
3. [Creation order](/api/ordem-de-criacao): what has to exist before each call, and where each id comes from.
4. [Responses and errors](/api/respostas-e-erros) and [Pagination](/api/paginacao).
5. [JavaScript SDK](/api/sdk-js), if you use JavaScript.
6. The [API Reference](/api/referencia), for every endpoint.

## What communities use the API for

| Use case | Example |
|---|---|
| CRM integration | Read the day's sales and create the contact in the CRM |
| Automating onboarding | Invite the student when enrollment happens in another system |
| Building content in bulk | Create a course with 30 lessons in one go |
| Reports | Export the statement to the finance team's spreadsheet |
| Your own interface | Show the community's events on the company website |
| Search | Find a post, event, course, space or call by title, ignoring accents and case, with [`GET /api/search`](/api/referencia/feed/get-search) |

## What your role allows

The API applies the same rules as the interface: the token belongs to a person, and what they can do depends on their [role](/conceitos/papeis-e-permissoes) in the community given in `X-CommunityId`. A regular member reads and takes part; people who manage create and configure.

## How the API changes

The API grows by addition: new endpoints and new fields appear without prior notice, and your code should ignore fields it doesn't recognize. The reference in this help center is generated from the specification itself on every release, so it always shows what is live.

## Reference

Every endpoint, with parameters, body, responses and a curl example, is in the [API Reference](/api/referencia), generated from the specification itself.

## For AI and code generation

- [`/docs.txt`](https://api.memberfy.net/docs.txt): a compact reference, handy to paste into an assistant. It accepts `?tags=Auth,Events` to send only what matters.
- [`/docs.json`](https://api.memberfy.net/docs.json): the full specification, for generating typed clients.

> [!NOTE]
> Some write endpoints (multipart uploads and a few POSTs) don't declare their body fields in the specification. In those cases, the endpoint's page says so, and the guide on that topic explains the fields.
