Previous Topic

Next Topic

Book Contents

Book Index

Accredo API Overview and Basics

The Accredo API is a Restful OData 4 JSON API and uses OAuth 2.0 for authorisation.

Details on the OData 4 specification can be found here: https://www.odata.org. To use the Accredo API, we recommend you read the OData basics to become familiar with the standard. A useful guide to OData 4 can be found at OData Basic Tutorial (http://www.odata.org/getting-started/basic-tutorial/).

The API service must be installed and configured on the client's server. A 64bit operating system is required.

A test system is available for developer testing at https://demo.accredo.co.nz

The API URL is: https://demo.accredo.co.nz:6569/saturn/odata4/v1/Company('demo')

Authorisation

The Accredo API uses OAuth 2.0 for authorisation, with an OAuth grant type of password.

For more information about OAuth 2.0, please see the specification here: https://oauth.net/2/

Note: UserName for OAuth 2.0 can be either an Accredo System User Code or the unique email address for a System User.

The demo system details are as follows:

Client_id: 3v7OstC8Bu6SESqM
Username: demo
Password: demo

The OAuth secret is not used, and scope is implied from the user being authenticated based on its Accredo permissions.

The OAuth endpoint is: https://demo.accredo.co.nz:6569/saturn/oauth2/v1/token

A sample request body posted to the token endpoint is:

{
    "grant_type":"password",
    "client_id":"3v7OstC8Bu6SESqM",
    "username":"demo",
    "password":"demo"
}

The response to this would be:

{
    "access_token": "wQ2pJxukkQPTulD3",
    "token_type": "bearer",
    "expires_in": 3600,
    "refresh_token": "ujRTfsCjlqww2Op3"
}

The OAuth access token can passed in the URL for a GET request, but for security it is recommended an authorization header be used instead. An authorization header is required for POST/PATCH/PUT/DELETE requests.

A full list of all our endpoints is available at:

https://demo.accredo.co.nz:6569/saturn/odata4/v1/Company('demo')/developerdoc?access_token=

This includes links to the metadata documentation for each of the endpoints, their properties and actions.

Common API Endpoints

The most commonly used Accredo API endpoints are:

/ARCustomerList
/ICProductList
/INInvoiceList
/OEOrderList

These return filterable lists for Customers, Products, Invoices, and Orders, the full records can then be found at their respective endpoints:

/ARCustomer('StringID')
/ICProduct('StringID')
/INInvoice(NumericID)
/OEOrder(NumericID)

More information on working with these OData endpoints, such as filtering and field selections can be found in the OData guide. Specifics such as available fields can be found in the API metadata.

Example API call

The following request will get the Customer record for the customer in our Demo system with code ASHENG, selecting the fields CustomerCode, CustomerName, and CustomerGroupCode.

GET https://demo.accredo.co.nz:6569/saturn/odata4/v1/company('DEMO')/ARCustomer('ASHENG')?$Select=CustomerCode,CustomerName,CustomerGroupCode&access_token=

This will return the following JSON body:

{
"@odata.context" : "https://demo.accredo.co.nz:6569/saturn/odata4/v1/Company('DEMO')/$metadata#ARCustomer/$entity",
"@odata.id" : "https://demo.accredo.co.nz:6569/saturn/odata4/v1/Company('DEMO')/ARCustomer('ASHENG')",

"@odata.etag" : "1",
"@odata.editLink" : "https://demo.accredo.co.nz:6569/saturn/odata4/v1/Company('DEMO')/ARCustomer('ASHENG')",
"CustomerCode" : "ASHENG",
"CustomerName" : "Asheng Engineering Ltd",
"CustomerGroupCode" : "0000"
}

Many of the endpoints, i.e /INInvoice have expandable sub-objects like 'Line' for invoice lines.These are not returned by default when making a call to the endpoint and need to explicitly expanded. An example of this, is shown below. This requests an invoice, selecting the fields CustomerCode, DocumentDate, GSTAmount and ExclusiveAmount, and expands the Line sub-object, selecting the ProductCode, QuantitySupplied, GSTAmount and ExclusiveAmount.

GET https://demo.accredo.co.nz:6569/saturn/odata4/v1/company('DEMO')/INInvoice(414)?$Select=CustomerCode,DocumentDate,GSTAmount,ExclusiveAmount&$Expand=Line($Select=ProductCode,QuantitySupplied,GSTAmount,ExclusiveAmount)&access_token=

This will return the following JSON body:

{
"@odata.`context": "https://demo.accredo.co.nz:6569/saturn/odata4/v1/Company('DEMO')/$metadata#INInvoice/$entity",
"@odata.etag": "10",
"CustomerCode": "SMITH",
"ExclusiveAmount": 7956.64,
"GstAmount": 1195.67,
"DocumentDate": "2025-09-28",
"[email protected]": "https://demo.accredo.co.nz:6569/saturn/odata4/v1/Company('DEMO')/$metadata#INInvoice(414)/Line",
"Line": [
{
"ProductCode": "SMLBOOKCASE",
"QuantitySupplied": 2,
"ExclusiveAmount": 849.87,
"GstAmount": 127.48
},
{
"ProductCode": "BEDSUITE",
"QuantitySupplied": 2,
"ExclusiveAmount": 0,
"GstAmount": 0
},
{
"ProductCode": "BEDCABINET",
"QuantitySupplied": 4,
"ExclusiveAmount": 1398.74,
"GstAmount": 209.81
},
{
"ProductCode": "DRESSTABLE",
"QuantitySupplied": 2,
"ExclusiveAmount": 1295.12,
"GstAmount": 194.27
},
{
"ProductCode": "STDCHEST",
"QuantitySupplied": 2,
"ExclusiveAmount": 1548.41,
"GstAmount": 232.26
},
{
"ProductCode": "QUEENBED",
"QuantitySupplied": 2,
"ExclusiveAmount": 2254.18,
"GstAmount": 338.13
},
{
"ProductCode": "STDBEDHEAD",
"QuantitySupplied": 2,
"ExclusiveAmount": 542.32,
"GstAmount": 81.35
},
{
"ProductCode": "OVALMIRROR",
"QuantitySupplied": 1,
"ExclusiveAmount": 68,
"GstAmount": 10.2
}
]
}

Selecting fields is not a requirement, but is useful for reducing the size of responses and only dealing with specific data you are interested in.

It is also possible to query the Accredo database tables directly via the /table_TableName endpoints, i.e /table_ICPROD for the ICPROD table which contains the product information. These endpoints do not have the combined sub-objects and are read-only. But they are useful for trying to request large volumes of data via the API.

Technical Documentation

Full technical documentation for the API is available from the topic here: Accredo API Technical Documentation.

Further Documentation

A full list of the available API endpoints can be found via the /DeveloperDoc endpoint. This contains links to each endpoint as well as endpoint metadata information.

Metadata is available to show both type and property data for endpoints.

/$metadata/$format=json
/$metadata/Types$format=json
/$metadata/Properties$format=json
/$metadata/Functions$format=json
/$metadata/Actions$format=json

And can request individual entities as :

/$metadata/Types('ARCUSTOMER')$format=json
/$metadata/Properties('ARCUSTOMER')$format=json

OpenAPI Documentation

We provide an endpoint to generate an OpenAPI 2.0 JSON file: /openapi.json.

Note: OpenAPI is not fully compatible with OData and there are differences between the generated documentation for OpenAPI and the correct query and parameter structure for OData. This endpoint is provided as a convenience only.