Skip to main content

Resources API Example Requests (CURL)

The examples below use admin authentication. See Authentication for the headers used by privileged and end-user authentication, and for which resources and operations each authentication type can use.

Example Requests (CURL)

Create a Resource (POST)

curl -X POST https://{API hostname}/resources/{resource name} \
-H "Content-Type: application/json" \
-H "X-Spaaza-Chain-ID: {chain_id}" \
-H "X-Spaaza-API-version: 1.6.1" \
-H "X-Spaaza-Session-User-ID: {your user ID}" \
-H "X-Spaaza-Session-Key: {your key}" \
-H "X-Spaaza-Response-Recursion-Level: 3" \
-d '{
"{parameter name 1}": "{string}",
"{parameter name 2}": {integer},
"{parameter name 3}": {float}
}'

Get a Resource by ID (GET)

curl -X GET https://{API hostname}/resources/{resource name}/{id} \
-H "X-Spaaza-Chain-ID: {chain_id}" \
-H "X-Spaaza-API-version: 1.6.1" \
-H "X-Spaaza-Session-User-ID: {your user ID}" \
-H "X-Spaaza-Session-Key: {your key}" \
-H "X-Spaaza-Response-Recursion-Level: 3"

Get a Resource by Identifier Parameter (GET)

curl -X GET "https://{API hostname}/resources/{resource name}?{identifier parameter}={value}" \
-H "X-Spaaza-Chain-ID: {chain_id}" \
-H "X-Spaaza-API-version: 1.6.1" \
-H "X-Spaaza-Session-User-ID: {your user ID}" \
-H "X-Spaaza-Session-Key: {your key}" \
-H "X-Spaaza-Response-Recursion-Level: 3"

Get List of Resources (GET)

curl -X GET "https://{API hostname}/resources/{plural resource name}?{filter_parameter_1}={value}&{filter_parameter_2}={value}&limit=10&offset=0" \
-H "X-Spaaza-Chain-ID: {chain_id}" \
-H "X-Spaaza-API-version: 1.6.1" \
-H "X-Spaaza-Session-User-ID: {your user ID}" \
-H "X-Spaaza-Session-Key: {your key}" \
-H "X-Spaaza-Response-Recursion-Level: 3"

Update a Resource (PATCH or PUT)

The PATCH and PUT methods can be used interchangeably to update resources. Below are examples for both methods.

# By identifier parameter
curl -X PATCH "https://{API hostname}/resources/{resource name}?{identifier parameter}={value}" \
-H "Content-Type: application/json" \
-H "X-Spaaza-Chain-ID: {chain_id}" \
-H "X-Spaaza-API-version: 1.6.1" \
-H "X-Spaaza-Session-User-ID: {your user ID}" \
-H "X-Spaaza-Session-Key: {your key}" \
-H "X-Spaaza-Response-Recursion-Level: 3" \
-d '{
"{parameter name 1}": "{string}",
"{parameter name 2}": {integer}
}'

# By ID
curl -X PATCH "https://{API hostname}/resources/{resource name}/{id}" \
-H "Content-Type: application/json" \
-H "X-Spaaza-Chain-ID: {chain_id}" \
-H "X-Spaaza-API-version: 1.6.1" \
-H "X-Spaaza-Session-User-ID: {your user ID}" \
-H "X-Spaaza-Session-Key: {your key}" \
-H "X-Spaaza-Response-Recursion-Level: 3" \
-d '{
"{parameter name 1}": "{string}",
"{parameter name 2}": {integer}
}'

Delete a Resource (DELETE)

# By identifier parameter
curl -X DELETE "https://{API hostname}/resources/{resource name}?{identifier parameter}={value}" \
-H "X-Spaaza-Chain-ID: {chain_id}" \
-H "X-Spaaza-API-version: 1.6.1" \
-H "X-Spaaza-Session-User-ID: {your user ID}" \
-H "X-Spaaza-Session-Key: {your key}" \
-H "X-Spaaza-Response-Recursion-Level: 3"

# By ID
curl -X DELETE "https://{API hostname}/resources/{resource name}/{id}" \
-H "X-Spaaza-Chain-ID: {chain_id}" \
-H "X-Spaaza-API-version: 1.6.1" \
-H "X-Spaaza-Session-User-ID: {your user ID}" \
-H "X-Spaaza-Session-Key: {your key}" \
-H "X-Spaaza-Response-Recursion-Level: 3"

Get List of Resources with Privileged Authentication (GET)

curl -X GET "https://{API hostname}/resources/{plural resource name}?limit=10&offset=0" \
-H "Authorization: Bearer {access token ID}:{access token secret}" \
-H "X-Spaaza-Chain-ID: {chain_id}" \
-H "X-Spaaza-API-version: 1.6.1" \
-H "X-Spaaza-Response-Recursion-Level: 3"

Get an End-User's Own Vouchers (GET)

curl -X GET "https://{API hostname}/resources/vouchers?limit=10&offset=0" \
-H "X-Spaaza-MyPrice-App-Hostname: {app hostname}" \
-H "X-Spaaza-API-version: 1.6.1" \
-H "X-Spaaza-Session-User-ID: {end-user ID}" \
-H "X-Spaaza-Session-Key: {session key}" \
-H "X-Spaaza-Response-Recursion-Level: 3"

End-user requests derive the chain from the X-Spaaza-MyPrice-App-Hostname header, so the X-Spaaza-Chain-ID header is not used.