Configuring StoreConnect to enable the API
There are several steps to set up StoreConnect to enable the API:
- Create a Custom Domain for the API
- Configure a new store record to respond to the API
- Request an API Key from support
These steps are covered below:
Create a custom domain for the API
To begin, you need to create a custom domain to use with the API. This MUST have "api" as the subdomain. So if your domain name is example.com, then you would need to create a custom domain called api.example.com. If your site was mysite.example.com.au then your api domain would be api.mysite.example.com.au.
To create a web domain to use with your stores, follow the Add a Custom Domain to Your Website article.
Once done and verified, move onto the next step:
Configure a store to be used for the API
Once you have the domain name, you need to make a new store record and set it's domain name to the one you created in the previous step, when complete, you should be able to visit your store (such as at api.mysite.example.com.au) and see the API documentation.
Once set up, the API can be accessed, and with the correct API key (see below) you can access any of your Stores regardless of the domain used.
Request an API key from support
In order to make requests to the API, your requests need to be authenticated with an API Key. In future you will be able to generate API keys from Salesforce, however for now you will need to ask our Support team to generate one for you.
In your Support request, please supply the Salesforce record ID of the Store that has the api domain name on it that you created in the previous step. This is how we know which Store has the API configured on it.
Please note: API keys should be kept secret. Anyone who has access to the API key could make requests to the API.
Testing the API
When you are ready to use the API, please visit https://api./ in your browser to view the API documentation.
Let's say your store Salesforce record ID is a2ABC001234 and your API key was 1234APIKEY5678 and your domain name was api.example.com then you can do a test request like this:
~ $ curl -H "Authorization: Bearer a2ABC001234:1234APIKEY5678" \
-H "Accept: application/json" \
-X GET https://api.example.com/v1/store
This should produce output like this:
{ "name":"Test Store","currency":{"code":"AUD","symbol":"$"}, "locale":"en","timezone":"Australia/Sydney" }