# @auth metadata directive. Instead of manually constructing Authorization headers, declare your auth method and hitspec handles the rest.
Syntax
{{variable}} interpolation.
Separate the parameters with commas (basic alice, s3cret) or with whitespace (basic alice s3cret). If the line contains a comma outside {{ ... }} it is split on commas, so a value may then contain spaces; a comma inside {{ ... }} (for example {{$random(1, 5)}}) never splits. For the OAuth2 grants, every parameter after the required ones is part of the scope list.
hitspec checks the method name and the number of parameters when it parses the file. An unknown method (@auth magic foo) or a wrong parameter count is a parse error: hitspec validate reports it and exits with code 2 instead of sending the request without credentials.
Methods
bearer
Sends anAuthorization: Bearer <token> header.
Generated header:
Authorization: Bearer <token>
basic
Sends a Base64-encodedAuthorization: Basic <credentials> header.
Generated header:
Authorization: Basic <base64(username:password)>
apiKey
Sends the API key as a custom request header.
Generated header:
<headerName>: <value>
apiKeyQuery
Appends the API key as a URL query parameter.
Effect: Appends
?api_key=<value> to the request URL.
digest
HTTP Digest authentication. hitspec handles the challenge-response handshake automatically.aws
Signs requests using AWS Signature Version 4 for AWS services or compatible APIs (e.g., MinIO, LocalStack).
If the fifth argument is left out and the access key equals
$AWS_ACCESS_KEY_ID, hitspec uses $AWS_SESSION_TOKEN when it is set. A >>>multipart body is signed over the exact bytes sent.