Make authenticated requests

An app can make authenticated requests to the Zencargo API using basic authentication, supplying a valid API key.

Basic Authentication

Zencargo uses Basic Authentication to authenticate calls to its public API.

You can generate these credentials in the Zencargo App Settings > API Keys section

Authenticating calls using basic authentication requires for you to provide these credentials in the Authorization header field as follows:

  1. Join the API Key ID and secret with a single colon (:).
  2. Encode the resulting string in base64 representation.
  3. Prepend the base64-encoded string with Basic and a space:
Authorization: Basic ODAxZGQzNzUtYTdlZS00NzQwLWE3OGYtMzdiM2ZjYWQ2MjFiOjI3Yks3UlMxQ21uZVhRY3g1YnBx

Hint: If you're on a Unix-like OS you can encode your key and secret with:

echo -n 'YOUR_API_ID:YOUR_API_SECRET' | base64

Here's an example request using the API Key we've generated and the API staging URL we were provided:

curl -X POST \
  https://zawesomedev.api.staging.zencargo.com/graphql \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Basic ODAxZGQzNzUtYTdlZS00NzQwLWE3OGYtMzdiM2ZjYWQ2MjFiOjI3Yks3UlMxQ21uZVhRY3g1YnBx' \
  -d ' { "query": "query { products { nodes { name skuCode } } }" }'

**You can ignore the data (-d) part for now, it is documented in details later when we send our first API call

Next Steps