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

# Finish connecting your books

> Redeem what QuickBooks Online or Xero sent the browser back with, and store the tokens.

Send the `code` and `state` the vendor put on the return address -- and, from QuickBooks, its
`realmId` -- in the body, never in a URL. The state is spent on first use, whatever follows, and
must have been issued to you in this organisation. The tokens are stored in the saved connection,
sealed, and never returned; the refresh token is stored again each time the vendor rotates it.

For Xero, the organisation is read from the app's connections: exactly one must be there.

It needs `credential.manage` -- Owner or Admin -- and a signed-in person.

> [!WARNING]
>
> AI employees are in **beta**. `404` as for [Start connecting your
> books](https://docs.mithunai.com/api-reference/employees/start-books-consent.md).

## Body

**code** `string` *required*

What the vendor sent back as `code`.

**state** `string` *required*

What the vendor sent back as `state`.

**realm\_id** `string`

QuickBooks only: what it sent back as `realmId`.

## Response

`201` with the saved connection, as [Connections](https://docs.mithunai.com/api-reference/connections/list-connections.md)
lists it. The tokens are not in it.


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