API
Introduktion
Det här dokumentet beskriver hur du använder vårt REST API för att integrera med vårt system. API ger åtkomst till funktionalitet såsom att skapa försäljningsorder. API:et utvecklas kontinuerligt och fler resurser läggs in.
Autentisering och auktorisering
För att använda API behöver du autentisera dig med en giltig API-nyckel. Autentisering sker genom OAuth 2.0, och varje anrop kräver en Bearer Token i Authorization-huvudet.
Din klient behöver registreras i GKS4 vilket är något Simutek hjälper till med. Därefter får du ett client_id och en client_secret som används för att erhålla en åtkomsttoken.
Exempel på hämtning av åtkomsttoken
Ett exempel hur access token kan hämtas med curl.
curl 'https://id.simutek.se/connect/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'client_id=your_client_id' \
--data-urlencode 'client_secret=your_client_secret' \
--data-urlencode 'grant_type=client_credentials'Ett exempel hur access token kan hämtas med Python 3 och Requests.
import requests
def fetch_access_token():
url = "https://id.simutek.se/connect/token"
headers = {
"Content-Type": "application/x-www-form-urlencoded"
}
data = {
"client_id": "YOUR_CLIENT_ID",
"client_secret": "YOUR_CLIENT_SECRET",
"grant_type": "client_credentials"
}
response = requests.post(url, headers=headers, data=data)
if response.status_code == 200:
access_token = response.json().get("access_token")
print(f"Access Token: {access_token}")
else:
print(f"Failed to fetch access token. Status Code: {response.status_code}")
print(response.text)
if __name__ == "__main__":
fetch_access_token()För att köra koden:
pip3 install requests
python3 get_access_token.pyEtt exempel hur access token kan hämtas med JavaScrpt (Node.Js):
const axios = require('axios');
const qs = require('qs'); // For URL-encoded data
async function fetchAccessToken() {
const url = 'https://id.simutek.se/connect/token';
const data = qs.stringify({
client_id: 'YOUR_CLIENT_ID',
client_secret: 'YOUR_CLIENT_SECRET',
grant_type: 'client_credentials'
});
try {
const response = await axios.post(url, data, {
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
});
console.log('Access Token:', response.data.access_token);
} catch (error) {
console.error('Failed to fetch access token:', error.response ? error.response.data : error.message);
}
}
fetchAccessToken();
För att köra koden:
npm install axios qs
node fetchAccessToken.jsHeaders
Om inte annat angivet kräver varje anrop åtminstone följande headers:
Authorization
Bearer eyJ...
Byt ut värdet eyJ... med din access token.
Content-Type
application/json
Dokumentation
Success. The customer was created.
No content
Bad request. The request is not well-formed or there is a validation error.
Not Found
Server error. An internal server error occured. Please try again later.
POST /api/v1/customers HTTP/1.1
Host:
Authorization: Bearer YOUR_OAUTH2_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 284
{
"name": "text",
"number": "text",
"invoiceEmail": "text",
"postalAddress": {
"address1": "Storgatan 1",
"address2": "Garageinfart 2",
"address3": "text",
"city": "Stockholm",
"zipCode": "114 44",
"state": "FL",
"countryCode": "SE"
},
"corporateIdentityNumber": "text",
"tags": [
{
"key": "text",
"value": "text"
}
]
}No content
The customer number.
Success. The company was found and returned.
Bad request. The request is not well-formed or there is a validation error.
Not found. The customer with provided customer number was not found.
Server error. An internal server error occured. Please try again later.
GET /api/v1/customers/{customerNumber} HTTP/1.1
Host:
Authorization: Bearer YOUR_OAUTH2_TOKEN
Accept: */*
{
"name": "text",
"number": "text",
"invoiceEmail": "text",
"postalAddress": {
"address1": "Storgatan 1",
"address2": "Garageinfart 2",
"address3": "text",
"city": "Stockholm",
"zipCode": "114 44",
"state": "FL",
"countryCode": "SE"
},
"corporateIdentityNumber": "text",
"tags": [
{
"key": "text",
"value": "text"
}
]
}Optional filter by exact customer number.
Optional filter by name, matches anywhere in the name.
Optional filter by corporate identity number. Spaces and dashes are ignored when matching.
Page number, starting from 1. Default is 1.
1Page size, maximum 100. Default is 50.
50OK
Bad Request
Internal Server Error
GET /api/v1/customers HTTP/1.1
Host:
Authorization: Bearer YOUR_OAUTH2_TOKEN
Accept: */*
{
"page": 1,
"limit": 1,
"totalCount": 1,
"customers": [
{
"number": "text",
"name": "text",
"corporateIdentityNumber": "text"
}
]
}The customer number in GKS of the buyer. A company with this customer number must exist in GKS.
K100421Optional name of the sales order that will be useful when searching for the order.
Obsolete. We do not see a business need to change the date of purchase. It should always be the same date as the order request is received.
An optional purchase order number from the buyer. In PlaceSimpleOrder API, "CustOrderNo".
The preferred language (ISO 639-1) of documents communicated with the buyer, i.e. order confirmation. Accepted values: sv, no, en
The currency of the amounts in this sales order. ISO 4217.
SEKA comment added by the customer during placement of the order. Commonly with instructions to the seller.
Success. The sales order was created.
Bad request. The request is not well-formed or there is a validation error.
Not found. The customer number was not found.
Server error. An internal server error occured. Please try again later.
POST /api/v1/salesorders HTTP/1.1
Host:
Authorization: Bearer YOUR_OAUTH2_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 1009
{
"customerNumber": "K100421",
"billingContact": {
"firstName": "text",
"lastName": "text",
"email": "text",
"phone": "text",
"phoneMobile": "text",
"eInvoiceCode": "text"
},
"billingCompanyInfo": null,
"billTo": null,
"shipTo": null,
"orderTitle": "text",
"promisedDeliveryDate": "2025-11-03T07:40:34.158Z",
"ordered": "2025-11-03T07:40:34.158Z",
"purchaseOrderNumber": "text",
"isExport": true,
"isExportWithinEu": true,
"languageCode": "text",
"currencyCode": "SEK",
"noteFromCustomer": "text",
"salesOrderlines": [
{
"articleNumber": "text",
"description": "text",
"quantity": 1,
"salesUnit": "text",
"unitPrice": 1,
"vatPercent": 1,
"discountPercent": 1,
"costWork": 1,
"costMaterial": 1,
"costSubcontractWork": 1,
"profitCenterCode": "14",
"weightPerUnit": 1,
"shipOrderline": true,
"allotments": [
{
"qtyToShip": 1,
"shipTo": {
"recipientName": "text",
"address": {
"address1": "Storgatan 1",
"address2": "Garageinfart 2",
"address3": "text",
"city": "Stockholm",
"zipCode": "114 44",
"state": "FL",
"countryCode": "SE"
},
"contactName": "text",
"contactMobilePhone": "text",
"contactEmail": "text"
}
}
]
}
]
}{
"orderNumber": 1
}Last updated