Connecting accounting software to Maventa over the API
Accounting software signs in to the Maventa REST API with three credentials: the company UUID, the user API key and the vendor API key. This article covers sign-in, scopes, the software vendor link and keeping the connection working.
- Credentials
- Signing in
- Scopes and user roles
- Software vendor link
- Retrieving the identifiers
- Keeping the connection working
- Common errors
Credentials
| Credential | Identifies | Where it comes from |
|---|---|---|
| Company UUID | The company account | The company's Maventa account |
| User API key | The user of that company | The company's Maventa account |
| Vendor API key | The software partner's software | Maventa integration care |
One partner can have several vendor API keys, for example one per product or country. Testing and production have separate credentials, and keys from one environment don't work in the other.
⚠️ A full user or vendor API key must never be shared with outsiders, including in screenshots, logs or code samples.
Signing in
Authentication is based on OAuth2. The accounting software requests a bearer token with POST /oauth2/token:
| Parameter | Value |
|---|---|
| grant_type | client_credentials |
| client_id | Company UUID |
| client_secret | User API key |
| vendor_api_key | Vendor API key |
| scope | The scopes the integration needs, separated by spaces |
The token expires after the time given in expires_in, in seconds. Recommended practice:
- The token is stored and treated as expired slightly before the server-side expiry time.
- A new token is requested when the old one expires.
- Token errors are handled gracefully, even when expiry is also tracked on the client side.
The token is a signed JSON, so its length can vary.
Scopes and user roles
Scopes: the scopes are listed in the scope parameter, for example scope=company lookup invoice:send invoice:receive. Without the parameter, the token gets the default scopes global and company. They cover company settings, documents and lookup, but not the invoice endpoints, so invoice calls then return 401 Unauthorized. The granted scopes are returned in the token response.
User role: the token has the rights of the user whose API key is used. Admin users get all requested scopes. Users with the user role don't get company:write, so they can't change company details or settings.
Unverified company: until the company account has been verified (Know Your Customer), the token only gets the scopes for company settings, lookup and validation. Sending and receiving become available after verification.
Software vendor link
The company account is linked to the software partner's vendor API key. Maventa uses the link to identify which software the company uses, for reporting and support. The link is also required for webhooks. A company account registered through the partner's software is linked automatically. An existing company account that starts using the software must be linked separately. The link can only be managed over the API:
| Method | Purpose |
|---|---|
| POST /v1/company/vendors | Links the vendor API key to the company account |
| GET /v1/company/vendors | Shows the link status |
| DELETE /v1/company/vendors | Removes the link, for example when the company stops using the software |
The vendor API key is taken from the authentication, so the requests need no other parameters. The requests need the company:write scope, so they must be made with an admin user's API key.
Retrieving the identifiers
The company UUID and user API key can't be retrieved over the API. The company's user copies them from the Maventa account and enters them in the accounting software. Step-by-step instructions can be found from User account - User API key and company UUID.
ℹ️ The company UUID and the company billing UUID are different identifiers. The billing UUID is the customer number on Maventa's service invoices.
Keeping the connection working
Removing a user: if the user whose API key the connection uses is removed from the company account, the connection is cut immediately. This applies both in the Maventa account and over the API. The safe order for changing the admin is described in User account - Consideration for API connection and user API key.
Resetting the API key: the key can only be reset in the Maventa account. The old key stops working immediately, so the new key must be entered in the accounting software straight away. Instructions can be found from User account - Resetting user API key.
Common errors
| Error | Likely cause |
|---|---|
| "The provided access grant is invalid, expired, or revoked" when requesting a token | Sign-in failed. The company UUID or user API key is wrong, testing credentials are used in production or the other way round, the user has been removed, the vendor API key is missing or invalid, or the company account is disabled. |
| 401 Unauthorized on an API call | The token lacks the scope the call needs, such as invoice:send or invoice:receive, or company:write for a user with the user role. Requesting a new token with the same credentials and scopes doesn't help. |
More answers are in Solving common integration issues. Technical details are in the Maventa documentation: REST API getting started and Companies and settings.