# patient.subscribed

Canonical page: https://docs.ovok.com/signals/standalone/webhooks/patient-subscribed

A patient is attached to the subscriber.

## Payload [#payload]

Every delivery is the envelope `type`, `timestamp`, `sequence` and `data`; the delivery's id is the `webhook-id` header. See [Verify webhooks](/signals/standalone/verify-webhooks).

```json
{
  "type": "patient.subscribed",
  "timestamp": "2026-10-25T08:00:02.000Z",
  "sequence": 1054,
  "data": {
    "patient": "6f1c2a8e-3b7d-4c55-9a0e-2d4b8f6e1a90",
    "subscriber": "ovok-sub-4f2a9c"
  }
}
```

`subscriber` is the subscriber the patient was attached to.

## Handle the event [#handle-the-event]

Verify the delivery first ([Verify webhooks](/signals/standalone/verify-webhooks)), then act on the verified event as in [Handle an event](/signals/standalone/webhooks#handle-an-event).

<Tabs items={["Node.js", "Python", "Java"]} groupId="language" persist>
<Tab value="Node.js">

```js title="patient-subscribed.js"
export async function handle(webhookId, event) {
  if (!(await firstTime(webhookId))) return;
  const { data } = event;
  switch (event.type) {
    case 'patient.subscribed':
      await trackPatient(data.patient);
      break;
    default:
      break;
  }
}
```

</Tab>
<Tab value="Python">

```python title="patient_subscribed.py"
def handle(webhook_id: str, event: dict) -> None:
    if not first_time(webhook_id):
        return
    data = event["data"]
    match event["type"]:
        case "patient.subscribed":
            track_patient(data["patient"])
```

</Tab>
<Tab value="Java">

```java title="PatientSubscribedHandler.java"
void handle(String webhookId, JsonNode event) {
  if (!firstTime(webhookId)) return;
  JsonNode data = event.get("data");
  switch (event.get("type").asText()) {
    case "patient.subscribed" -> {
      trackPatient(data.get("patient").asText());
    }
    default -> {}
  }
}
```

</Tab>
</Tabs>

## Related [#related]

- [Webhooks basics](/signals/standalone/webhooks)
- [Verify webhooks](/signals/standalone/verify-webhooks)
