Authentication
Sign every Sub-user API request with AWS Signature V4, service zata, using one of your own root access keys.
Every request to the Sub-user API is signed with AWS Signature V4, the same scheme S3 uses. You sign with one of your own root access keys. The secret key never travels; only the signature does.
Most tools that can sign an S3 request can sign these too. You only change the service name to zata.
The signing rules
| Item | Rule |
|---|---|
| Algorithm | AWS4-HMAC-SHA256, in the Authorization header. |
| Credential scope | <access key>/<YYYYMMDD>/<region>/zata/aws4_request. The service must be zata. |
| Region in the scope | Any value works; it is only used to derive the signing key. Use us-east-1. |
| Signed headers | Must include host. Every header you list in SignedHeaders must be sent. |
x-amz-date | Required, in the form YYYYMMDDTHHMMSSZ, on the same day as the scope date, and within 15 minutes of Zata's clock. A Date header does not replace it. |
| Body hash | The signature always covers the SHA-256 of the exact body bytes. x-amz-content-sha256 is optional; if you send it, it must be that hash. UNSIGNED-PAYLOAD and streaming payloads are refused. |
| Path | Signed exactly as sent. Ids, bucket names, regions and rule ids only use letters, digits, -, _, . and ~, so no encoding is needed. |
| Query string | Sorted and encoded the standard SigV4 way. |
Content-Type | Send Content-Type: application/json on every request with a body. Without it, the body is not read and the signature does not match. |
The key must be an active root key of an account that has Sub-user API access turned on. See Requirements.
Repeating a write
A signed POST, PUT, PATCH or DELETE can be sent once. Sending the same signed request again returns 409 CLI_REQUEST_REPLAYED, and that copy does not run. The first copy may already have made the change, for example when its answer was lost to a timeout. Read the current state before you sign the request again, or the change can happen twice. To repeat an operation on purpose, sign it again: a new x-amz-date gives a new signature. Both examples below sign every call afresh, so you only see this error if you resend a saved request. GET requests can be repeated.
Request ID
Send x-request-id with 8 to 64 characters (A-Z a-z 0-9 . _ -) to pick your own id for a request, for example to match it in your logs. Otherwise Zata makes one. Either way it comes back in the X-Request-Id response header once the request is authenticated, and the dashboard notification for a write names it.
Ids you never have to send
- Your account id. Use
meinGET /subusers/parent/meto list your sub-users. Sign the path withmein it.
curl
curl 7.75 or later signs requests with --aws-sigv4. Put your root key in two environment variables first:
export ZATA_ACCESS_KEY="EXAMPLEACCESSKEY0001"
export ZATA_SECRET_KEY="EXAMPLEsecretKEY000000000000000000000001"
- Read
- Write
- Write with a body
# List your sub-users
curl --aws-sigv4 "aws:amz:us-east-1:zata" \
--user "$ZATA_ACCESS_KEY:$ZATA_SECRET_KEY" \
"https://cli.zata.ai/cli/v1/subusers/parent/me"
# Rotate one key of a sub-user (the body, if any, is signed too)
curl --aws-sigv4 "aws:amz:us-east-1:zata" \
--user "$ZATA_ACCESS_KEY:$ZATA_SECRET_KEY" \
-H "Content-Type: application/json" \
-X POST \
"https://cli.zata.ai/cli/v1/subusers/$SUBUSER_ID/keys/$KEY_ID/rotate"
# Suspend a sub-user in one region
curl --aws-sigv4 "aws:amz:us-east-1:zata" \
--user "$ZATA_ACCESS_KEY:$ZATA_SECRET_KEY" \
-H "Content-Type: application/json" \
-X POST --data '{"suspended": true, "regions": ["idr01"]}' \
"https://cli.zata.ai/cli/v1/subusers/$SUBUSER_ID/suspend"
aws:amz:us-east-1:zata tells curl: provider aws, region us-east-1, service zata. Always pass -H "Content-Type: application/json" when you send --data; otherwise curl sends a form content type.
Python
The Python examples on every page of this reference use the call() helper below. It signs with botocore's SigV4Auth and sends with requests. Install both:
pip install botocore requests
import json, os, requests
from botocore.auth import SigV4Auth
from botocore.awsrequest import AWSRequest
from botocore.credentials import Credentials
BASE = "https://cli.zata.ai/cli/v1"
creds = Credentials(os.environ["ZATA_ACCESS_KEY"], os.environ["ZATA_SECRET_KEY"])
def call(method, path, body=None):
"""Sign and send one Sub-user API request. Returns (status, JSON body)."""
data = json.dumps(body) if body is not None else None
headers = {"Content-Type": "application/json"} if data is not None else {}
req = AWSRequest(method=method, url=BASE + path, data=data, headers=headers)
SigV4Auth(creds, "zata", "us-east-1").add_auth(req) # adds X-Amz-Date, signs host and body
r = requests.request(method, req.url, headers=dict(req.headers), data=data)
return r.status_code, r.json()
print(call("GET", "/subusers/parent/me"))
- Put query parameters in the path:
call("GET", "/subusers/parent/me?status=active"). - Each
call()signs again, so repeating a write never hits the replay guard. - Use
SigV4Auth. botocore's S3-specific signer can sendUNSIGNED-PAYLOAD, which this API refuses.
When signing fails
| Code | Most likely cause |
|---|---|
CLI_AUTH_REQUIRED | No Authorization header, or not a SigV4 one. |
CLI_WRONG_SERVICE | The scope says s3 or something else instead of zata. |
CLI_DATE_INVALID, CLI_REQUEST_EXPIRED | x-amz-date missing, or your clock is more than 15 minutes off. |
CLI_AUTH_FAILED | Wrong secret key, a key that doesn't exist, or a body sent without Content-Type: application/json. |
CLI_KEY_NOT_ROOT | You signed with a sub-user's key. Use one of your own keys. |
CLI_NOT_ENABLED | Sub-user API access is off on the Access Keys page. |