How to get started with the Xchain API
This guide will help you get started with the Xchain API service! All the important stuff – request parameters, example responses, possible response codes, etc – is documented here, but should you have any questions, always feel free to reach out to support@xchaintechnology.com.
Get started with a test environment using your test API key. All test API requests are free and return fake data, and do not affect your live data or interact with ERP systems. The API key you use for authentication determines whether the request is in live or test mode.
sk_test_aed12HbPqeWXzcbvfT1zdp4y
.
$ curl https://api.xchaintechnology.com/v1/matches\
-u sk_test_4eC39HqLyjWDarjtT1zdp7dc:
# The colon prevents curl from asking for a password.
[
{
"id": "ma_8TYhvTwcVF9tJc2gLfVqTdT4",
"object": "match",
"invoice": {
"id": "in_qLnHAJ7hFDTbKW5XqfD6ktQB",
"object": "invoice",
...
},
"po": {
"id": "po_SzGFZneLuYGVwy8dSZZzZat4",
"object": "po",
...
},
"receivable": {
"id": "rc_qxPVveaPCd5KcHVhVjNHDt8v",
"object": "receivable",
...
},
...
}
]
That's it! You've successfully completed a request to the Xchain API.
The Xchain API uses alphanumeric keys to authenticate requests. You can manage your API keys in the Xchain Dashboard.
Test mode secret keys have the prefix sk_test_
and live mode secret keys have the prefix sk_live_
. You can generate more restrictive API keys (than the default) for added security.
Your API keys carry many privileges, so be sure to keep them secure! Do not share your secret API keys in publicly accessible areas such as GitHub, client-side code, and so forth.
Authentication to the API is performed via HTTP Basic Auth. Provide your API key as the basic auth username value. You do not need to provide a password.
If you need to authenticate via bearer auth (e.g., for a cross-origin request), use -H "Authorization: Bearer sk_test_4eC39HqLyjWDarjtT1zdp7dc"
instead of -u sk_test_4eC39HqLyjWDarjtT1zdp7dc
.
All API requests must be made over HTTPS. Calls made over plain HTTP will fail. API requests without authentication will also fail.
Xchain uses conventional HTTP response codes to indicate the success or failure of an API request. In general: codes in the 2xx range indicate success. Codes in the 4xx range indicate an error given the information provided (ex: a required parameter was omitted, a charge failed, etc.). Codes in the 5xx range indicate an error with Xchain's servers, which rarely happen.
Some 4xx or 5xx errors that can be handled programmatically (ex: an invoice scan has failed) include an error code that briefly explains the error reported.