# Martia workspace API Martia connects a financial workspace to an assistant after its owner approves access. [Public prices](https://api.martia.app/pricing.md) and [list prices in JSON](https://api.martia.app/v1/billing/prices) are available before authorization. ## Connection methods | Client | Connection | | --- | --- | | Chat assistant that can send HTTP requests | The device flow below returns a link the person can open. It works without installing an MCP server or receiving a callback. | | MCP host with OAuth | Streamable HTTP at https://api.martia.app/mcp with OAuth discovery. | | Application with a callback URL | Authorization code with PKCE. The issuer metadata is at https://api.martia.app/.well-known/oauth-authorization-server. | | Already connected | The existing OAuth connection supports REST and MCP. The first workspace operation for a conversation turn is `check_in`. | ### Device flow for a chat assistant 1. **Client registration, once per client.** `POST https://api.martia.app/experimental/oauth/register` accepts JSON such as `{"client_name":"My finance assistant","grant_types":["urn:ietf:params:oauth:grant-type:device_code"],"token_endpoint_auth_method":"none"}`. For a standard workspace connection, including a bank or a budget, the registration body omits `scope`. The client retains the returned `client_id`. 2. **Approval link.** `POST https://api.martia.app/experimental/oauth/device_authorization` accepts form-encoded `client_id`. The device request also omits `scope` for standard workspace jobs. Optional `ui_locales` (for example `pl`) sets the language of the approval page and the preview a chat app shows. The response includes `verification_uri_complete` for the person, the matching `user_code` and a private `device_code` for the client. The person signs in and selects a workspace on Martia. 3. **Token exchange.** At the returned `interval`, the client polls `POST https://api.martia.app/experimental/oauth/token` with form-encoded `grant_type=urn:ietf:params:oauth:grant-type:device_code`, `client_id` and `device_code`. While pending it receives `authorization_pending`. On `slow_down` the interval increases by five seconds. The client stores the access and refresh tokens privately and sends the access token to the API as a Bearer credential. One approval grants the ordinary workspace permissions together. The permissions in the jobs table describe what each operation checks. Explicit `preferences:user` or `preferences:workspace` are only needed for a request involving those preferences. A bank consent, a credit purchase and publication of a shared report each have their own person-facing handoff. The owner can revoke the connection in Settings → Integrations. ## First workspace call `check_in` corresponds to `POST https://api.martia.app/v1/agent/check-ins`. Each conversation turn has a fresh UUID in `checkInId`. The body records what the person said about the task in `userMessage`, the answer in `agentMessage`, or `nothingNew: true` if there is no update. It needs no additional scope. Its briefing includes the connected banks, existing budget months, workspace notes and saved dashboards available to the connection. After five minutes without a workspace operation, a call can return `409 check_in_required`. A fresh check-in with the conversation update (or `nothingNew: true`) allows the original operation to be retried on the same connection. ## Jobs and permissions | Person's request | Operations | Workspace access and handoff | | --- | --- | --- | | Check or connect a bank | `check_in`, `bank_list`, then `bank_institutions` and `bank_connect` if needed | The briefing lists existing connections, sync status, monthly unit cost and available units. A syncing bank needs no new consent. Connecting a new bank needs `banks:manage` and the account holder’s approval. | | Understand spending | `list_transactions`, `get_budget_summary` | `finance:read`. The briefing supplies context for interpreting transfers and existing plans. | | Plan a monthly budget | `get_budget_summary`, `set_budget_amount` | `finance:read` for the existing plan and `finance:write` for changes. | | Review investments and net worth | `get_investment_portfolio`, `get_net_worth` | `finance:read`. Valuation dates and coverage accompany the figures. | | Make a dashboard or PDF from a conversation | `create_dashboard` with `story`, or `create_budget_brief` for a budget report | An existing connection can use estimates and budget figures. Ledger figures need `finance:read`. A table dashboard using `definition` needs `dashboards:write` and `finance:read`. | | Share a saved dashboard | `share_dashboard` | The owner receives the private `approvalUrl`. After publication the same operation returns the password-protected recipient `url`. | A `403 insufficient_scope` response identifies the missing permission in `details.requiredScopes` and the authorization request in `details.requestScope`. The person decides whether to approve that access. A paid operation that returns HTTP 402 can include a ready Stripe Checkout URL in `details.checkoutUrl`. The payer confirms the one-time pack on Stripe with their own card. The top-up price is separate from the action cost. This handoff needs no additional Martia login or spending approval. After Stripe confirms payment and the units arrive, the original operation can be retried. ## References - [REST and MCP examples](https://api.martia.app/v1/agent-reference.md) - [Authentication, renewal and revocation](https://api.martia.app/auth.md) - [OpenAPI operation schemas](https://api.martia.app/v1/openapi.json) - [API reference](https://api.martia.app/v1/docs)