Skip to content

Testing with curl

Every request in these docs has a curl command under it that you can copy and run as is. Spay gives you your client credentials and webhook signing secret during onboarding. The commands read your credentials from shell variables, so set them once per terminal session:

Terminal window
export SPAY_CLIENT_ID='<client-id>'
export SPAY_CLIENT_SECRET='<client-secret>'

Then get an access token and keep it in SPAY_ACCESS_TOKEN (this uses jq):

Terminal window
response=$(curl --fail-with-body -sS -X POST 'https://auth-dev.spay.ng/api/v1/oauth/token' \
-H "Accept: application/json" \
--data-urlencode "client_id=$SPAY_CLIENT_ID" \
--data-urlencode "client_secret=$SPAY_CLIENT_SECRET" \
--data-urlencode "grant_type=client_credentials") \
&& token=$(jq -er .access_token <<< "$response") \
&& export SPAY_ACCESS_TOKEN="$token" \
|| echo "Token request failed: $response" >&2

If the request fails, SPAY_ACCESS_TOKEN keeps its previous value and the error is printed. The token lasts an hour. When a command returns 401, run the command above again.

Account numbers, customer IDs, references, amounts and file names in the examples are samples. Replace them with your own values before you run a command. Upload commands read the named files from the current directory.