# Introduction

The MoneyMonk API lets you read and write bookkeeping data from MoneyMonk administrations on behalf of a user. It can be used to integrate MoneyMonk with other applications. To use the API, you must have a registered OAuth client. We provide client registration on a case-by-case basis for selected partners and integrations. See [Requesting access](./requesting-access) for how to apply.

Access works through OAuth 2.0: from your own application, you send the user to MoneyMonk to sign in, where they select one of their administrations and consent to the access you request. MoneyMonk then issues your application an access token scoped to that administration, which you can use to call the API on the user's behalf. To access another administration, the user goes through the flow again.

## API surface

Currently, the API covers only part of the functionality available in MoneyMonk, and the surface will be expanded over time. For an up-to-date overview of what's available, see the [API reference](/api), which lists all endpoints grouped by tag.


## Base URL

All requests go to:

```
https://api.moneymonk.nl
```

The API is versioned in the URL. Endpoints that are not finalized yet live under the `/v0` prefix; finalized endpoints live under `/v1`. The public API is still evolving, so currently all resource endpoints are under `/v0`. See [Versioning](#versioning) for what this means for your integration. Resource endpoints follow the pattern:

```
/v0/administrations/{administrationId}/{resource}
```

The `administrationId` path parameter selects the administration to operate on. Use the `GET /v0/administrations` endpoint to discover the administrations the current access token grants access to.


## Requests and responses

- All request and response bodies are JSON, with the exception of the OAuth 2.0 token and revocation endpoints, which accept `application/x-www-form-urlencoded` as required by [RFC 6749](https://datatracker.ietf.org/doc/html/rfc6749).
- Monetary amounts use the same representation in requests and responses; see [Monetary amounts](#monetary-amounts). MoneyMonk is a Dutch bookkeeping platform — currencies other than EUR are not supported on the public API.
- Fractional quantities are sent as strings; see [Quantities](#quantities).
- Dates and timestamps use ISO 8601.
- List endpoints that may return many items are paginated. The following query parameters are used for pagination:
  - `page` - Page number. One-based, defaults to `1`.
  - `per_page` - Page size. Defaults to `25`, clamped to the maximum page size of `100`.


### Monetary amounts

Monetary amounts use the same representation in both requests and responses: an object containing the currency and the amount as a decimal string. For example, a `price` field with a value of € 12.34 is represented as:

```json
"price": {
  "currency": "EUR",
  "amount": "12.34"
}
```

The currency is included for reference only; EUR is the only supported currency.


### Quantities

Fractional quantities are sent as strings rather than JSON numbers, so that decimal values can be represented exactly. For example, a `quantity` field with a value of 2.5 is represented as:

```json
"quantity": "2.5"
```

When precision matters and you want to do calculations with these quantities, parse them as decimal numbers (using a decimal type in your language) rather than as binary floating-point numbers, to avoid introducing roundoff errors.


## Authentication

Every request must include an OAuth 2.0 access token in the `Authorization` header:

```
Authorization: Bearer <access_token>
```

Access tokens are obtained through the OAuth 2 authorization code flow with PKCE. See [Authentication](./authentication) for instructions on how to retrieve an access token.


## Scopes

Scopes follow a `resource:action` naming convention. A client should request only the scopes it actually needs. Requesting `*:write` does **not** imply `*:read`; request both if you need both.

| Scope | Grants |
|-------|--------|
| `gla:read` | Read the chart of accounts (general ledger accounts) on an administration. |
| `order:read` | Read order books and the orders they contain. |
| `product:read` | Read products. |
| `product:write` | Create and modify products. |
| `vat-code:read` | Read VAT codes. |
| `contact:read` | Read contacts. |
| `sales-invoice:read` | Read sales invoices. |
| `sales-invoice:write` | Create and modify sales invoices. |
| `file:write` | Upload files. |

The authoritative, machine-readable list of currently supported scopes is always available via the [discovery document](./authentication#discovery).

Access tokens are additionally bound to the single administration the user selected on the consent screen. Calls referencing any other `administrationId` will fail with `403 Forbidden`, even if the requested scope is otherwise satisfied.


## Error responses

The API returns errors in the following format:

```json
{
  "error": {
    "code": 26,
    "message": "Deze HTTP-methode wordt niet ondersteund voor dit endpoint.",
    "httpStatus": "METHOD_NOT_ALLOWED"
  }
}
```

Resource endpoints return a `401 Unauthorized` with a `WWW-Authenticate: Bearer` header when the access token is missing, invalid, or expired. Refresh the token and retry, or restart the authorization flow if the refresh token has also expired.


## Versioning

The API is versioned in the URL, using two prefixes:

- **`/v0`** — Endpoints that are not finalized yet. Their interface may still change in backwards-incompatible ways, so build against them with care.
- **`/v1`** — Finalized endpoints. We won't make breaking changes to them; a breaking change would result in a new version.

An endpoint moves from `/v0` to `/v1` once its interface is finalized and we commit to not breaking it. The public API is still evolving, so currently all endpoints are under `/v0`.

Additive changes (new fields, new objects, new endpoints, new scopes) are considered backwards compatible and may be made to any version without a bump. Regardless of version, clients should ignore unknown JSON fields and unknown enum values they don't recognize.
