Sessions and Public API calls
A partner token manages companies and users; it cannot read or write accounting data. To work inside a company, mint a session for one of its users and call the Public API with it.
Mint a session
Working in your own language? These samples use plain HTTP. You can generate a typed Partner API client from openapi-partner.json with the same generators; see SDKs and client libraries.
curl https://api.paprel.com/v1/partner/companies/<company_id>/sessions \
--request POST \
--header 'Authorization: Bearer <partner token>' \
--header 'Content-Type: application/json' \
--data '{ "external_user_id": "user-0001" }'
Name the user with user_id or external_user_id, or send several in users. A session always names a user; there is no company-only session.
Each result carries an access_token for that user in that company, with expires_in, expires_at and the session's permissions:
- Lifetime is set on your credential, between 300 and 900 seconds. Mint a new session when it expires. A session stops earlier if you deactivate its user or suspend its company.
- Permissions are the user's current role, capped by your agreement.
- Read-only: a company without a subscription, or under a read-only licence, receives a read-only session.
- Ownership is checked on every call: the company, the user and the membership must all belong to you.
Mint sessions on your server. If a browser needs one, return only the session token, never the partner token or key.
Call the Public API
A session token is an App Connect token for one user in one company. Call any Public API operation the user's role allows, and send x-partner-domain set to your partner identity domain (the token's pdomain claim). That header is required on Public API calls; the Partner API routes do not use it.
curl https://api.paprel.com/v1/accounting/accounts \
--header 'Authorization: Bearer <session token>' \
--header 'x-partner-domain: <your partner identity domain>'
From here the company works like any other:
| Task | Call |
|---|---|
| Read the chart of accounts | GET /v1/accounting/accounts |
| Add a client | POST /v1/clients |
| Add a product or service | POST /v1/items (item_type is goods or service) |
| Raise an invoice | POST /v1/invoices |
| Post a manual journal | POST /v1/accounting/journals |
For a worked example from partner token to posted journal, see Your first accounting entry.
Next: limits and lifecycle.