Il prompt d'integrazione
Paste the block below into Claude Code, Codex, Cursor or any coding agent working in your repository. Replace the two lines marked <…>. The agent needs nothing else from GroceryAI: the contract, the examples and the error pages are public, and the only secret is the test key you put in the environment.
You are integrating this repository with the GroceryAI Platform API.
Goal: <describe what to build, e.g. "push our product catalog every night and pull confirmed orders into our order table">.
Our stack: <language, framework, where config and secrets live>.
Sources of truth (fetch them, do not answer from memory):
- OpenAPI 3.1 contract, no key needed: https://qgdwytendnvkldxmbvpu.supabase.co/functions/v1/core-api/v1/openapi.json
Every operation has a tested request and response example; response schemas are closed, never invent fields.
- Error catalog, no key needed: GET /v1/errors and GET /v1/errors/{code} on the same base URL. Every error response
carries error.doc_url pointing to its page: read it when a call fails, it says how to fix the request.
Credentials:
- The API key is in the environment variable GROCERYAI_API_KEY. It is a test key (gai_test_...): it only sees test
data. Never print, log, commit or hard-code the key, and never send it anywhere except the GroceryAI base URL.
Do not switch to a live key (gai_live_...); that is a human decision.
Working steps:
1. Download the contract and list the operations and scopes the goal needs.
2. Make the first call before writing any code: GET /v1/products?limit=1 with "Authorization: Bearer $GROCERYAI_API_KEY".
A 200 proves the key; a 401/403 tells you why in error.code and error.doc_url. If the key lacks a scope, stop and
tell me which scope to add; do not work around it.
3. Implement against the contract, applying the rules that concern the operations your goal uses:
- every write carries a fresh Idempotency-Key (UUID v4) per logical operation, reused only to retry the same body;
- batch writes take at most 500 items; always check errors[] and warnings[] in the 200 response;
- paginate with next_cursor -> cursor until it is null (it is present only when there really is another page, so
the last page, even a full one, needs no extra request);
- branch on error.code (never on message); on 429 wait Retry-After; on 5xx retry with the same Idempotency-Key;
- log the request_id of every failed call;
- error.code, error.type and values such as stato are stable Italian identifiers; error.message is Italian free
text for humans: never parse it.
4. Prove it against the test environment: run the integration end to end, show me the real responses (status, counts,
errors[]), and add automated tests that use the documented examples as fixtures.
5. Report: the operations used, the scopes required, what you ran and what it returned, and anything you could not
verify. Do not claim success without a real response from the API.Why each line is there: the public contract and error pages let the agent work without our help; the test key keeps every experiment away from real customers; idempotency, batch checks and error.code branching are the rules that otherwise get guessed wrong; the last step stops an agent from declaring "done" on code it never ran.
The same rules, as a file to keep in your repository: AGENTS.md. The five steps for a person: quickstart.md.