Goto APIs

Integration API

General:

Basics:

Base-URL: https://capi.lagerkoll.com/v1/integration/
Parameters in the url should all be encoded and all data sent should be UTF-8

MAX number of requests per minute is set to 200.
When the limit is hit an error with code 429 is returned, with the header "Retry-After" containing the number of seconds you have to wait for your next request.

Headers:

There are 2 ways to be authenticated when using this API. in both ways you add headers to the request.
1) Use an API-key together with store-id. This would be used when communicating machine to machine and no real person is involved. The API-key is available from where you activated the API. The store-id is also available in the same place.
2) Use a user_id and user_token together with a store-id. You get these values from the login-request. The values are connected to a person and are gained when an actual login to the system has been made.
store: <<STORE>>
user_id: <<USER_ID>>
user_token: <<USER_TOKEN>>
api_key: <<API_KEY>>
Accept: application/json
Content-Type: application/json

Errors:

Code Description
900001 Credentials don't match
900101 Common error
900429 Too many requests
905001 Error when authenticating to integration
905002 Wrong state
905003 Error posting to visma
905004 Error for integration
905005 Error for external integration
905006 Error posting to fortnox
905007 Error posting to BankID
{
  "errorCode" : 900101,
  "errorMessage" : "Something went wrong on the server",
  "errorField" : null,
  "errorData" : null
}

Integration API:

BankID

BankID check status

GETUrl: /bankid/{order_ref}/status
Headers:
Accept: application/json
Content-type: application/json
Check authentication status from BankID. If user is logged in the success of authentication will automatically connect the logged in user with the ssn from BankID. If user is not logged in and ssn is not found in Lagerkoll, the ssn is returned to client. Otherwise the user is logged in and a new valid webtoken is returned.

Valid parameters:

Parameter Description Default value Allowed values
invite_user_id User id for inviting a new user who wants to login with BankID
invite_user_key Invite key for inviting a new user who wants to login with BankID

Body:
Successfull response:

{ "accountId": 434, "orderRef": "orderRef", "qrCode": "qrCode", "hint": "hint", "storeId": 978, "status": "status", "ssn": "ssn", "token": "token" }

BankID start authentication

POSTUrl: /bankid/start_auth
Headers:
Accept: application/json
Content-type: application/json
Start BankID authentication using either QR Code or logging on to the same device
Body:
Successfull response:

{ "autoStartToken": "autoStartToken", "orderRef": "orderRef" }

BankID cancel

POSTUrl: /bankid/{order_ref}/cancel
Headers:
Accept: application/json
Content-type: application/json
Cancel ongoing authentication
Body:
Successfull response:

External Integration

Get credentials

GETUrl: /external
Headers:
Content-type: application/json or application/xml
Get external integration credentials
Body:
Successfull response:

{"credentials": [{ "integration": "integration", "allowedMethods": [{}] }]}

Add credentials

POSTUrl: /external
Headers:
Content-type: application/json or application/xml
Create new external integration credentials
Body:

{ "authorizationMethod": "DEFAULT", "values": {}, "integration": "integration", "allowedMethods": [{}] }
Successfull response:

{ "integration": "integration", "allowedMethods": [{}] }

Redirect request

POSTUrl: /external/request
Headers:
Content-type: application/json or application/xml
Redirects requests to external integrations and returns the data. Before the request is redirected credentials will be added. Credentials can be either in the headers-list, in the url or in the body. If a credential is left blank either in the header or in the url, the system will try to find the exact same key in the stored credential and replace the value with that. But a credential could also have the format {{my_key}} and the system will then replace my_key with the stored credential value of that key. This is how it must be done if you have credentials in the body-field
Body:

{ "headers": {}, "method": "method", "integration": "integration", "formDataPartName": "formDataPartName", "body": {}, "url": "url", "formDataFilename": "formDataFilename" }
Successfull response:

Update credentials

PUTUrl: /external/{integration}
Headers:
Content-type: application/json or application/xml
Update existing external integration credentials
Body:

{ "authorizationMethod": "DEFAULT", "values": {}, "integration": "integration", "allowedMethods": [{}] }
Successfull response:

{ "integration": "integration", "allowedMethods": [{}] }

Remove credentials

DELETEUrl: /external/{integration}
Headers:
Content-type: application/json or application/xml
Remove existing external integration credentials
Body:
Successfull response:

Fortnox

Get fortnox settings

GETUrl: /fortnox/settings
Headers:
Content-type: application/json or application/xml
Get what data will be synced between Lagerkoll and Fortnox, get fortnoxLager, only active articles and default vat account
Body:
Successfull response:

{ "defaultSalesAccount": 6525, "onlyActiveArticles": true, "supplier": 7999, "customerOrder": 9209, "fortnoxLager": false, "article": 1933, "customer": 4996 }

Create integration to Fortnox

POSTUrl: /fortnox/auth
Headers:
Accept: application/json or application/xml
Content-type: application/json or application/xml
Authenticate integration to Fortnox
Body:

{ "syncOnlyActiveArticles": "true", "code": "code", "supplier": 2500, "customerOrder": 8143, "state": "state", "syncFromLagerkoll": false, "error": "error", "article": 5341, "customer": 574 }
Successfull response:

Update fortnox settings

PUTUrl: /fortnox/settings
Headers:
Content-type: application/json or application/xml
Update fortnoxLager, only active articles and vat account from Fortnox settings
Body:

{ "defaultSalesAccount": 8982, "onlyActiveArticles": false, "supplier": 8822, "customerOrder": 86, "fortnoxLager": false, "article": 8405, "customer": 1390 }
Successfull response:

Integration

Get status

GETUrl: /status
Headers:
Accept: application/json
Content-type: application/json
Get status for your integration
Body:
Successfull response:

Test integration

GETUrl: /test/{type}
Headers:
Accept: application/json or application/xml
Content-type: application/json or application/xml
Make a test request for the active integration
Body:
Successfull response:

Send custom request

POSTUrl: /custom
Headers:
Accept: application/json or application/xml
Content-type: application/json or application/xml
Send custom request
Body:

{"path": "path"}
Successfull response:

Sync integration

PUTUrl: /sync
Headers:
Accept: application/json
Content-type: application/json
Start a sync of integration where changed data from external system will be synced to Lagerkoll
Body:
Successfull response:

Remove integration

DELETEUrl:
Headers:
Accept: application/json or application/xml
Content-type: application/json or application/xml
Remove integration and stop all sync messages
Body:
Successfull response:

Visma

Get Visma settings

GETUrl: /visma/settings
Headers:
Content-type: application/json or application/xml
Get what data will be synced between Lagerkoll and Visma
Body:
Successfull response:

{ "supplier": 4339, "customerOrder": 3578, "article": 813, "customer": 9697 }

Create integration to Visma

POSTUrl: /visma/auth
Headers:
Accept: application/json or application/xml
Content-type: application/json or application/xml
Authenticate integration to Visma
Body:

{ "code": "code", "supplier": 4739, "customerOrder": 7242, "state": "state", "error": "error", "article": 2056, "customer": 1989 }
Successfull response:

Visma single sign on

POSTUrl: /visma/login
Headers:
Accept: application/json
Content-type: application/x-www-form-urlencoded
Callback request from Visma single sign on
Body:
Successfull response:

Update Visma settings

PUTUrl: /visma/settings
Headers:
Content-type: application/json or application/xml
Update what data will be synced between Lagerkoll and Visma
Body:

{ "supplier": 6040, "customerOrder": 6545, "article": 9722, "customer": 8291 }
Successfull response:

Classes:

BankIDAuthResponse

Field Type Description Default Mandatory Accepted values Example values Access
orderRef String Session's order reference number R
autoStartToken String Token to use to build a link to automatically start BankID on client. The url to start the application on the same device looks like this: https://app.bankid.com/?autostarttoken=[autoStartToken]&redirect=null R

BankIDStatusResponse

Field Type Description Default Mandatory Accepted values Example values Access
orderRef String Session's order reference number R
status String Session's status FAILED, PENDING, COMPLETE R
hint String Error hint from BankID R
ssn String Social security number of the successfully authenticated BankId user R
accountId Long R
storeId Long R
token String API token for logged in user R
qrCode String Dynamic qr code used for logging in R

ExternalCredentials

Field Type Description Default Mandatory Accepted values Example values Access
integration String Name of integration Post R,W
allowedMethods List List of accepted methods for this integration Post GET,POST,PUT,DELETE R,W

ExternalCredentialsRequest

Field Type Description Default Mandatory Accepted values Example values Access
integration String Name of integration Post R,W
values HashMap Map of credentials (Key, value) Post R,W
allowedMethods List List of accepted methods for this integration Post GET,POST,PUT,DELETE R,W
authorizationMethod String Authorization method to use when redirecting external requests DEFAULT DEFAULT,WOO_COMMERCE R,W

ExternalCredentialsResponse

Field Type Description Default Mandatory Accepted values Example values Access
credentials List R

ExternalRequest

Field Type Description Default Mandatory Accepted values Example values Access
integration String Name of integration Post R,W
method String What type of method is the request Post GET,POST,PUT,DELETE R,W
url String Url of the final destination Post R,W
headers HashMap Headers to be redirected to final destination Post R,W
body Object Body to be redirected to final destination Post R,W
formDataPartName String If headersĀ“ Content-Type is set to multipart/form-data the body will be treated as Base64 encoded data that will be redirected to final destination with this fields value as the key R,W
formDataFilename String If headersĀ“ Content-Type is set to multipart/form-data the body will be treated as Base64 encoded data that will be redirected to final destination with this fields value as the filename R,W

FortnoxAuthenticate

Field Type Description Default Mandatory Accepted values Example values Access
article Integer Sync articles between Lagerkoll and Visma 0 = none, 1 = from lagerkoll, 2 = to lagerkoll, 3 = both ways R,W
supplier Integer Sync suppliers between Lagerkoll and Visma 0 = none, 1 = from lagerkoll, 2 = to lagerkoll, 3 = both ways R,W
customer Integer Sync customers between Lagerkoll and Visma 0 = none, 1 = from lagerkoll, 2 = to lagerkoll, 3 = both ways R,W
customerOrder Integer Sync customer orders between Lagerkoll and Visma 0 = none, 1 = from lagerkoll, 2 = to lagerkoll, 3 = both ways R,W
syncFromLagerkoll Boolean If first sync should be done from Lagerkoll to Fortnox set this flag to true, otherwise false true R,W
syncOnlyActiveArticles Boolean If only active articles should be synced true R,W
code String Authentication code from Fortnox login callback R,W
state String State from Fortnox login callback R,W
error String If error sent from Fortnox login callback R,W

FortnoxSettings

Field Type Description Default Mandatory Accepted values Example values Access
article Integer Sync articles between Lagerkoll and Visma 0 = none, 1 = from lagerkoll, 2 = to lagerkoll, 3 = both ways R,W
supplier Integer Sync suppliers between Lagerkoll and Visma 0 = none, 1 = from lagerkoll, 2 = to lagerkoll, 3 = both ways R,W
customer Integer Sync customers between Lagerkoll and Visma 0 = none, 1 = from lagerkoll, 2 = to lagerkoll, 3 = both ways R,W
customerOrder Integer Sync customer orders between Lagerkoll and Visma 0 = none, 1 = from lagerkoll, 2 = to lagerkoll, 3 = both ways R,W
onlyActiveArticles Boolean Check for syncing only active articles from Fortnox R,W
fortnoxLager Boolean Check if Fortnox Lager is activated R,W
defaultSalesAccount Integer Preselected sales account where sales account on article is missing in Fortnox R,W

IntegrationCustomRequest

Field Type Description Default Mandatory Accepted values Example values Access
path String The path to send the request to true R,W

VismaAuthenticate

Field Type Description Default Mandatory Accepted values Example values Access
article Integer Sync articles between Lagerkoll and Visma 0 = none, 1 = from lagerkoll, 2 = to lagerkoll, 3 = both ways R,W
supplier Integer Sync suppliers between Lagerkoll and Visma 0 = none, 1 = from lagerkoll, 2 = to lagerkoll, 3 = both ways R,W
customer Integer Sync customers between Lagerkoll and Visma 0 = none, 1 = from lagerkoll, 2 = to lagerkoll, 3 = both ways R,W
customerOrder Integer Sync customer orders between Lagerkoll and Visma 0 = none, 1 = from lagerkoll, 2 = to lagerkoll, 3 = both ways R,W
code String Authentication code from Visma login callback R,W
state String State from Visma login callback R,W
error String If error sent from Visma login callback R,W

VismaSettings

Field Type Description Default Mandatory Accepted values Example values Access
article Integer Sync articles between Lagerkoll and Visma 0 = none, 1 = from lagerkoll, 2 = to lagerkoll, 3 = both ways R,W
supplier Integer Sync suppliers between Lagerkoll and Visma 0 = none, 1 = from lagerkoll, 2 = to lagerkoll, 3 = both ways R,W
customer Integer Sync customers between Lagerkoll and Visma 0 = none, 1 = from lagerkoll, 2 = to lagerkoll, 3 = both ways R,W
customerOrder Integer Sync customer orders between Lagerkoll and Visma 0 = none, 1 = from lagerkoll, 2 = to lagerkoll, 3 = both ways R,W