> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ecomail.cz/llms.txt
> Use this file to discover all available pages before exploring further.

# Register a push click

> Report push notification click tokens so taps are attributed to the campaign or automation that sent them.

When Ecomail sends a push notification, it adds a click token named `ecm_push_id` to the FCM message `data` payload, next to `deep_link`. Post that token back to this endpoint when the recipient taps the notification, and Ecomail attributes the click to the campaign or automation that sent it.

For `web` recipients with an `https` deep link, Ecomail also adds the token to the link the browser opens (`webpush.fcm_options.link`) as the `ecm_push_id` query parameter.

> [!NOTE]
>
> Ecomail only adds `ecm_push_id` when the notification has a deep link and the recipient is a known subscriber. A notification without a deep link carries no token, and there is nothing to report.

Ecomail counts each token once. A token sent again, in a later request or twice in one batch, adds no click, so you can safely retry a request that failed. You can batch up to 500 tokens in a single request.

**ecm\_push\_id** `array|string` *required*

Click tokens read from the `ecm_push_id` value in the notification's `data` payload, or from the `ecm_push_id` query parameter of the link opened on the web. Send an array of 1 to 500 tokens, or a single token as a plain string. Each token can be up to 2048 characters.

## Responses

The status code tells you how many of the tokens Ecomail accepted:

* `204` — every token was accepted. The response has no body.
* `200` — some tokens were rejected. The accepted ones are still registered, and `rejected` says how many were not.
* `422` — none of the tokens were accepted, or the `ecm_push_id` field itself failed validation. Nothing was registered.

A token is rejected when it is malformed, was not issued by Ecomail, or belongs to a different account than the API key you used.

```bash cURL theme={null}
curl -X POST https://api2.ecomailapp.cz/push/click \
  -H "key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "ecm_push_id": [
      "eyJpdiI6IkV4YW1wbGVJdiIsInZhbHVlIjoiRXhhbXBsZUVuY3J5cHRlZENsaWNrVG9rZW4ifQ=="
    ]
  }'
```

```php PHP theme={null}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api2.ecomailapp.cz/push/click');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'key: YOUR_API_KEY',
    'Content-Type: application/json',
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'ecm_push_id' => [
        'eyJpdiI6IkV4YW1wbGVJdiIsInZhbHVlIjoiRXhhbXBsZUVuY3J5cHRlZENsaWNrVG9rZW4ifQ==',
    ],
]));
$response = curl_exec($ch);
curl_close($ch);
```

```json 204 theme={null}
```

```json 200 Some tokens rejected theme={null}
{
  "rejected": 1
}
```

```json 422 Missing field theme={null}
{
  "errors": {
    "ecm_push_id": ["The ecm push id field is required."]
  }
}
```

```json 422 Invalid token theme={null}
{
  "errors": {
    "ecm_push_id": ["The ecm_push_id is invalid."]
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.