# Installing Sponsored Next Actions (for coding agents)

Your user asked you to add Sponsored Next Actions to their API. Follow these steps, and check with the user wherever a step says to.

## 1. Detect the backend

Look at the project to identify the framework:

- `express` in package.json → use `snippets/express.js`
- `fastapi` in requirements or pyproject → use `snippets/fastapi.py`
- `next` in package.json with an `app/` directory → use `snippets/nextjs.ts`

If it's something else, tell the user it isn't supported yet and stop. Point them to SPEC.md if they want to implement it themselves.

## 2. Add the snippet

Copy the matching file from this repo at the same version tag (`v0.1`) into the project, for example `lib/next-actions.js`. Don't modify the network URL or the fail-open behavior.

## 3. Ask the user two things

1. **Which routes should include offers?** Suggest the ones that complete a user action (bookings, orders, confirmations) and leave out auth, admin, payments and anything returning personal data.
2. **Which context fields are safe to share?** Show them the default allowlist in the snippet. Never add names, emails, phone numbers, addresses, account IDs or payment details.

## 4. Wire it up

Register the middleware or wrapper on the routes the user chose. Add `SNA_KEY=` to the project's example env file and tell the user to set their real key. Don't commit a real key.

## 5. Verify

Run the project's existing tests. Then confirm both of these:

- With `SNA_KEY` set to an invalid value, responses are unchanged (fail open).
- Response time on wrapped routes increases by no more than about 150ms.

## 6. Report back

Tell the user which routes are wrapped, which fields are shared, and where to set their key.
