Importing data into Custobar

Custobar has five different types of data.

  • Customers - Usually your registered customers or customers from your loyality program if you have one.
  • Events - Customer events, such as email subscriptions, browsing products online and participation in competitions.
  • Products - Product catalog.
  • Shops - Brick-and-mortar locations and e-commerce sites.
  • Sales - Sales order items.

The identifying fields of the five data types, such as external_id and nin of the customer, are free form strings that can be defined by you.

File transfer

To import your data to Custobar, you can use the Custobar API. Below are examples using curl to upload the data.

In all the examples below, replace mycompany with your company name as it is used in your company's Custobar app.


curl -X POST -u USER -H "Content-Type: application/json" \
    --data-binary @customers.json


curl -X POST -u USER -H "Content-Type: application/json" \
    --data-binary @events.json


curl -X POST -u USER -H "Content-Type: application/json" \
    --data-binary @products.json


curl -X POST -u USER -H "Content-Type: application/json" \
    --data-binary @shops.json


curl -X POST -u USER -H "Content-Type: application/json" \
    --data-binary @sales.json


Custobar supports two methods of authenticating the api calls: basic authentication with user's username and password, and token authentication using a user's access token.

Basic authentication

A Custobar user's username and password can be used for authentication, using the standard HTTP basic authentication, as is done in the curl examples above, e.g.

curl -X POST -u USER:PASS -H "Content-Type: application/json" \
    --data-binary @customers.json

Token authentication

Instead of supplying a password, requests may be authenticated using an access token. This has some advantages over basic authentication: the user's password need not be passed around in plain text, and checking the access token is much more efficient than checking a password, resulting in faster api calls.

An access token is acqured using the api itself:

curl -X GET -u USER

The reply to the request is a json object with one property: token.

  "token": "2d928b51b88ac31f0c8fda203770f0cdb1d5926b"

This token is then sent in Authorization header to authenticate without password (Here using it to authenticate customer data import):

 curl -X POST \
    -H "Authorization: Token 2d928b51b88ac31f0c8fda203770f0cdb1d5926b" \
    -H "Content-Type: application/json" \
    --data-binary @customers.json

A user may have one valid access token at a time. The /api/auth/access-token/ api call always returns this valid token. To invalidate the existing token and generate a new one, there is another api call, accepting POST requests:

curl -X POST -u USER

The reply to /api/auth/new-access-token is similar to /api/auth/access-token, but with a new valid token.

Secure FTP

It's also possible to use sftp to transfer the files. Files are transferred to directory /srv/sftp/mycompany/tocustobar on your Custobar server.

For further details, please contact Custobar technical assistance.