Sync from a REST API

Use the REST API source for any system that returns its stores as JSON: an in-house database, an online tool, a CRM or an ERP. In most cases you only fill in the API’s address and its login. Where the list of stores sits in the answer, and how the API splits it into pages, is detected when you test the connection. This guide is part of Data Sync; for the add-on itself, see Import & Sync.

Using Salesforce? Follow the Salesforce guide.

Fill in the Connect Step

Start a new sync task, choose REST API and fill in:

Field What to enter
Name Filled in for you with the API’s name or host and today’s date, such as “REST API (api.example.com) – Nov 3, 2026”. Change it to a name you recognise.
API URL The address that returns the list of stores, for example https://api.example.com/v1/stores. Query parameters, such as a filter, can be part of it.
Login None, API key, Bearer token, Username and password or OAuth 2.0. See Which Login to Choose.
Advanced settings Path to the stores, paging, extra headers. Leave them as they are at first: Test connection fills in what it detects. See Advanced Settings.
The Connect step for a REST API with an API key login, and the Advanced settings open with the path to the stores and the paging filled in by Test connection

Which Login to Choose

The API’s documentation says how to log in. Look for these words:

Login The API’s documentation mentions Fields
API key A key name such as X-Api-Key, apikey or ?api_key= Name ( the name the API expects for the key ), Value, and Send in: Header or URL parameter, as the documentation says
Bearer token Authorization: Bearer <token> Token
Username and password Basic authentication Username, Password
OAuth 2.0 A token URL, a client ID and a client secret Token URL, Client ID, Client secret, Scope, Username (optional), Password (optional)

For OAuth 2.0:

  • With only the token URL, client ID and client secret, the client credentials flow is used. Fill in Username (optional) and Password (optional) only when the API needs the password flow.
  • Fill in Scope only when the API asks for one.
  • The client ID and secret are sent in the request body. When the token URL wants them as HTTP Basic instead, they are sent that way. The access token is kept until it expires, and a new one is fetched when the API refuses it.

When another task already logs in to the same site, the step offers Use the same login details.

Advanced Settings

Click Advanced settings to open them. After a successful Test connection they show what was detected. Check them, and only change them when the API’s documentation says otherwise.

Path to the Stores

Where the list of stores is in the answer, as a path with dots, for example data.stores. Leave it empty to find it automatically. Then the list is found:

  • at the top of the answer, when the answer is the list;
  • in a Salesforce answer, under records;
  • in an OData answer ( for example Microsoft Dynamics 365 and other OData services ), under value, or d.results for OData version 2;
  • in GeoJSON, under features;
  • under a key named data, results, items, stores, locations, rows or entries, at the top or one level down;
  • or else as the first list of objects in the answer.

Paging

How the API splits a long list into pages. Detect works for most APIs.

Paging What it does
Detect
Default

Looks at each answer for a link to the next page, such as Salesforce’s nextRecordsUrl, OData’s @odata.nextLink, or next, links.next, next_page_url, meta.next or pagination.next; for a Link header with rel="next"; for a page count such as total_pages, last_page or the X-WP-TotalPages header; or for an offset with a limit.

On Test connection it fills in what it found: Paging and, for a next link, Path to the next link. When it finds no paging, Paging stays on Detect, so an API that starts paging later is still followed.

None One request. The answer holds every store.
Next link Path to the next link: where the address of the next page is in the answer, for example links.next. header:link reads it from the Link header. The run stops when there is no next link. The next page must be on the same site.
Page number Page parameter ( default page ), First page ( default 1 ), Page size parameter ( leave it empty when the API has none ) and Page size ( default 100 ). The run stops at an empty page, or at the last page when the API gives the number of pages.
Offset Offset parameter ( default offset ), Limit parameter ( default limit ) and Page size ( default 100 ). The run stops at an empty page, or when it has read the total the API reports.

Your other query parameters stay in the address exactly as you wrote them; only the page, size, offset and limit parameters are set.

When the API reports a total ( Salesforce’s totalSize, OData’s @odata.count, the X-Total-Count or X-WP-Total header, or a total next to the list ), a run that reads fewer stores fails with “The API reported N stores but only M were read.” It doesn’t import part of the list, because the rest would look removed.

A run reads at most 1,000 pages, at most 8 MB per page and at most 20 MB in all.

Extra Headers

Extra headers: only when the API asks for them, one Name: Value per line, sent with every request. For example Accept-Language: en.

Extra headers are stored as plain text. Never put a key or token there: put an API key under Login > API key instead, where it’s stored encrypted and can be sent in any header. Authorization and Cookie headers are refused in Extra headers; use the login fields.

How the Answer Becomes Columns

Each store in the list becomes one row. Its fields become columns on the Map fields step:

  • A nested object becomes columns with dots, such as address.city and address.geo.lat, up to four levels deep. Such a column is matched by its last part, so address.city is mapped to City for you.
  • A list of values, such as tags, becomes one column with the values separated by commas. A list of objects is left out.
  • Salesforce’s attributes and OData’s @odata.… fields are left out.
  • In GeoJSON, the properties become the columns, and a point adds latitude and longitude.
  • A top-level _id is shown as id when there is no id.

A column named id, ID, uuid, store_id or location_id, or a CRM name like CustomerID, is mapped to External ID for you, so a renamed store is still found. CRM names such as BillingStreet or ShippingPostalCode are matched too. Each store field gets at most one column: when two columns match the same field, the first one is mapped.

Test It

Click Test connection. It reads the first page and says how many stores it found, such as “Connected. 240 rows found.” When the API gives no total and has more pages, it says how many are on the first page instead: “Connected. 100 rows on the first page.” It also fills in the detected path and paging under Advanced settings. Check those, then click Next: Map fields.

Want to try the source first? https://jsonplaceholder.typicode.com/users is a free public test API with 10 rows and nested fields such as address.street and address.city.

Security

  • A login is only sent over https. With any login other than None, the API URL, and for OAuth 2.0 the token URL, must start with https://.
  • Secrets are stored encrypted. The key, token, password and client secret are encrypted with your site’s AUTH_KEY ( or WPSL_ENCRYPTION_KEY, when your wp-config.php defines it ). Without one they are not saved. The form never shows a saved secret: the field says it’s saved, with the last four characters of a key or token. Leave it empty to keep it.
  • A login is not sent to another site. It’s tied to the site of the API URL ( and of the token URL ) you entered it for. When you change the URL to another site, you enter the login again. A next-page link on another site isn’t followed, and with a login an API URL that redirects to another site is refused.
  • Only public addresses are read. An address on your own network, or on the server itself, is refused.
  • Secrets stay out of messages. When an API repeats a key or token in its error text, it’s taken out before the message is shown, saved in the History or mailed.

Troubleshooting

Message What it means and what to do
The API needs a login (401). Choose how to log in under Login. The API doesn’t answer without a login. Choose the login type its documentation names. The API’s own words follow on the next line.
The API refused the login (403). Check the login details. The key, token or password is wrong, has expired, or may not read this data.
The token URL refused the login: invalid_client — …. The client ID or client secret is wrong, or the secret expired. Copy them again, or create a new secret.
The token URL refused the login: invalid_grant — …. The app may not use this flow, or the user it runs as is missing. For Salesforce, see the Salesforce guide.
The token URL answered with HTTP 404. The token URL is wrong. Copy it from the API’s documentation.
A login is only sent over https. The API URL or the token URL starts with http://. Use the https:// address.
The URL now points to another site, so enter the login details again. The API URL or token URL is on another site than when the login was saved. Enter the login again.
The API URL redirects to another site: …. Enter that address as the API URL. The API moved, and a login is never sent along to another site. Use the address the message names.
The API answered with HTTP 400. The API didn’t understand the request, often a mistake in a query parameter. The API’s own words follow the message.
The API asked to slow down (429). The API limits how many requests you may make. Run the task less often, or use a larger Page size.
The response is not JSON. The URL returns a web page or another format. Check the address in the API’s documentation. For a CSV file, use the CSV URL source.
The API returned no stores.
or “No list of stores was found at …”
The list is empty, or not where Path to the stores says. Empty that field to find it automatically, or enter the right path.
The API reported N stores but only M were read. Paging stopped early. Under Advanced settings, set Paging to what the API’s documentation says.
The API says there are more stores, but not how to get the next page. The answer has a flag like has_more, but no next link or page count. Set Paging under Advanced settings.
The API sent the same page again, so the import stopped. The API ignores the page or offset parameter. Check the parameter names in its documentation.
The next page is on another site (…), so it is not followed. The API’s next link points to another host. Ask the API’s provider, or use Page number or Offset paging.
One page from the API is larger than 8 MB. Set Paging, or a smaller Page size, so the stores come in smaller pages.
The API has more than 1,000 pages, so the import stopped before reading them all. Use a larger Page size, if the API allows it.
Extra headers can’t contain Authorization or Cookie; use the login fields. Move the key or token to Login.

Next