Automations

How to connect to the easySales API: OAuth clients and personal access tokens

How to connect to the easySales API: OAuth clients and personal access tokens

Create OAuth clients and personal access tokens for the easySales API, choose the right grant type and scopes, and keep your connections from logging each other out.

What API settings are for

The easySales API lets your own systems and your partners' systems read and change your data: products, stock, orders, invoices and more. API Settings is where you create the credentials they use. Open it from Settings → Account → Settings with the API Settings button, or from Page settings → Integrations → API Settings.

Three things to know first:

  • One live token per connection. When a system asks for a new token, the previous token of the same connection stops working. Give each system its own client, and let it reuse its token instead of asking for a new one every time.
  • A personal access token is shown only once. Copy it when you create it. If you lose it, create a new one; the old one stops working.
  • Choose the scopes carefully. A token can do only what its scopes allow, and the scopes cannot be changed later.
The API Settings page: OAuth Client with three clients — ERP connector (Password grant), Online shop (Website grant) and Reports dashboard (Redirect flow) — with their client ID and secret, Authorized Applications with Online shop and its scopes, and Personal Access Tokens with Fulfilment partner.
Clients, authorized applications and personal access tokens on one page.
Section What it holds
OAuth Client The clients your systems use to get tokens, with their Client ID, Grant type and Secret.
Authorized Applications The applications that hold a token from one of your website or redirect clients, with their scopes. Revoke stops one.
Personal Access Tokens Your personal access tokens, by name. Delete stops one.
The API Settings page

Create an OAuth client

  1. Press Create new client.
  2. Give it a Name you will recognise, for example the name of the system that will use it.
  3. Choose the Grant type. For Redirect Flow Grant, also enter the redirect URL of your application.
  4. Press Create. The client appears in the list with its Client ID and Secret.
The Create client form: Name Online shop 2, Grant type Website Grant with its explanation, and Create.
Give each system its own client.
Grant type Use it for
Website Grant An online shop module or a custom shop connected to easySales. Next to the client ID and secret, it uses the website token of the shop, which you get when you connect the shop under Integrations.
Password Grant Your own system that gets its token with the login details of your easySales account.
Redirect Flow Grant An application where you approve the access in easySales and are sent back to the application. The redirect URL must use a host name, such as localhost or a domain, not an IP address.
Which grant type to choose

Edit changes only the name and the redirect URL. To change the secret, create a new client, switch your system to it, then Delete the old one. Deleting a client stops every token issued with it at once.

Create a personal access token

A personal access token is a ready-made token for a script, a tool or a partner that only needs to call the API.

  1. Press Create new token.
  2. Give it a Name, and tick the Scopes it needs, or Select all.
  3. Press Create, and copy the token right away.
The Create Token form: Name Warehouse app, the Scopes with Select all, and read-products, read-orders, update-orders and update-stock ticked.
Tick only the scopes the token needs.
The new personal access token, with the message that this is the only time it will be shown.
Copy the token now: it is not shown again.

Your account has one personal access token at a time: creating a new one ends the previous one. If two partners need access, give them OAuth clients instead.

Use the API

  • Send requests to https://easy-sales.com/api/v2, with the headers Authorization: Bearer followed by your token, and Accept: application/json.
  • Tokens are valid for one year. Keep the token and reuse it until then.
  • Your account can make up to 500 requests per minute, shared by all its tokens.
  • The endpoints, the fields and examples are in the API documentation at api.easy-sales.com.
📖
Read next
How to connect a custom shop to easySales with the API
Connect any custom or unsupported shop platform to easySales through the API: the two credentials you need, pushing products and stock, sending orders, and getting changes back.
→

Your team and API settings

Team members with the View settings permission can open API Settings and see your OAuth clients, including their secrets, but cannot create, edit or delete them, and do not see personal access tokens. Give that permission only to people who should have access to your API credentials.

When something does not look right

Symptom What to do
The API answers "Unauthenticated." The token was replaced by a newer one from the same client, or it expired. Use one client per system and keep the token it got.
The API answers "Invalid scope(s) provided." The token does not have the scope for this request. Create a new token with the scope ticked.
I lost my personal access token It cannot be shown again. Create a new one; the old one stops working.
The API returns a web page instead of JSON Add the header Accept: application/json to your requests.
"Too Many Attempts." Your account went over 500 requests per minute. Slow down your requests and reuse your token.
A partner lost access when I created a token Creating a personal access token ends the previous one. Give each partner its own OAuth client.
Common problems

Frequently asked questions

In Settings → Account → Settings, with the API Settings button. Create an OAuth client or a personal access token there.

A newer token was issued for the same client, or the token expired after one year. Each client keeps only its latest token.

No. It is shown only when you create it. Create a new one if you lost it.

No. Scopes are set when the token is created. Create a new token with the scopes you need.

Create a new client, switch your system to it, then delete the old client. Deleting it stops its tokens at once.

Up to 500 requests per minute for your account, shared by all its tokens.

At api.easy-sales.com, with the endpoints, fields and examples.

Was this guide helpful?