# Build your first action

Add one endpoint to your API and connect it so the dimmi agent can tell a customer which plan they are on.

In this guide, you will add one endpoint to your API and wire it up as an action. By the end, the dimmi agent can check a customer's plan live in the messenger.

Before you start, make sure you have:

- **A public HTTPS API** you can deploy to.
- **The dimmi agent** turned on in the messenger. See [Set up the dimmi agent](/ai/set-up-the-agent/).
- **Identity verification** turned on in the messenger. See [Identity verification](/developers/messenger/identity-verification/).

<Steps>

1. Add an endpoint that returns a customer's plan and checks a bearer token, then deploy it.

   ```js title="server.js"
   import express from "express";

   const subscriptions = {
     cus_1042: { plan: "Team", status: "active", renews_on: "2027-03-01" },
   };

   const app = express();

   app.get("/subscriptions/:customerId", (req, res) => {
     if (req.get("Authorization") !== `Bearer ${process.env.DIMMI_ACTIONS_TOKEN}`) {
       return res.status(401).json({ message: "Invalid token" });
     }
     const subscription = subscriptions[req.params.customerId];
     if (!subscription) {
       return res.status(404).json({ message: "No subscription for this customer" });
     }
     res.json(subscription);
   });

   app.listen(3000);
   ```

   Swap out the `subscriptions` object for a real lookup in your database. The keys match the customer IDs your identity tokens send in `sub`.

2. Open **Settings → Actions** and add a **REST API** connection. Enter your API's base URL and paste the value of `DIMMI_ACTIONS_TOKEN` as the bearer token.

3. Inside that connection, click **New action** and fill in these fields:

   | Field | Value |
   | --- | --- |
   | **Title** | `Check a subscription` |
   | **Instructions for the agent** | `Use when the customer asks which plan they are on, whether it is active, or when it renews.` |
   | **What it does** | **Only reads data** |
   | **Endpoint** | `GET` `/subscriptions/{contact.external_id}` |

   dimmi fills `{contact.external_id}` from the verified customer's `sub` claim. The AI model cannot change it.

4. Open the **Test** tab and run a **Live** test with a real ID, such as `cus_1042`. Check that the JSON response looks right.

5. Click **Publish**.

6. Open your site as a signed-in customer and ask the messenger, "Which plan am I on?" The agent calls your endpoint and replies with the customer's plan.

</Steps>

Ready to let the agent make changes with confirmation and approval? Read [Connect actions to your systems](/ai/actions/).

---

Index of all dimmi docs: https://trydimmi.com/llms.txt (full text: https://trydimmi.com/llms-full.txt)
