API Quick Start
Generate your first PDF with the Sheets To Labels Business API
1. Create an API key
Open API Key Settings and create a key. Business accounts can keep up to five active keys.
Keep the key in a server-side secret manager or environment variable. Never put it in browser JavaScript, public source code, or a mobile application bundle.
For this example, set the key in your terminal:
export SHEETS_TO_LABELS_API_KEY="sk-your-api-key"2. Save a template
Open the Label Designer while signed in, customize a template, and select Save Template. Wait for the Cloud synced message, then copy the custom-... Template ID. You can retrieve it later from API Templates in API Key Settings.
3. Generate a PDF
http_code=$(curl --silent --show-error \
-X POST https://sheetstolabels.com/api/v1/generate-pdf \
-H "Authorization: Bearer $SHEETS_TO_LABELS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"templateId": "custom-1234567890",
"variables": {
"code": "ag193",
"qrUrl": "https://example.com/ag193",
"name": "Test Ambassador"
}
}' \
--output api-response.bin \
--write-out "%{http_code}")
if [ "$http_code" = "200" ]; then
mv api-response.bin card-ag193.pdf
echo "Saved card-ag193.pdf"
else
jq . api-response.bin
fiA successful response has HTTP status 200 and Content-Type: application/pdf. Errors use application/problem+json, so this example checks the status before naming the response as a PDF. If jq is not installed, open api-response.bin as a text file to read the error.
4. Use the request ID when you need help
Every response includes an X-Request-Id header. Error responses also include requestId in the JSON body. Include that value when contacting technical support.