---
title: "Send a push notification"
description: "Send a push notification through Truememory's FCM credential.\n\nTarget with exactly one of ``user_ids`` (resolved through the device\nregistry), ``tokens`` (raw registration tokens you manage yourself), or\n``topic``/``condition`` (FCM-side fan-out).\n\nPer-device failures are reported in ``results`` rather than failing the\nrequest; only an upstream FCM failure returns an error status. Tokens FCM\nreports as dead are dropped from the registry and flagged ``pruned``."
---

> Documentation Index
> Fetch the complete documentation index at: https://truememory-docs.mvstg.com/llms.txt
> Use this file to discover all available pages before exploring further.

Path: AI Gateway API › Notifications

`POST /notifications/push`

Send a push notification through Truememory's FCM credential.

Target with exactly one of ``user_ids`` (resolved through the device
registry), ``tokens`` (raw registration tokens you manage yourself), or
``topic``/``condition`` (FCM-side fan-out).

Per-device failures are reported in ``results`` rather than failing the
request; only an upstream FCM failure returns an error status. Tokens FCM
reports as dead are dropped from the registry and flagged ``pruned``.

## Authentication

- `HTTPBearer`, http, header `Authorization`

## Header parameters

- `X-App-Id` (`send_push.header.X-App-Id`; any of, optional)
  - any of: `string`, `null`
- `X-On-Behalf-Of` (`send_push.header.X-On-Behalf-Of`; any of, optional)
  - any of: `string`, `null`
- `X-External-User-Id` (`send_push.header.X-External-User-Id`; any of, optional)
  - any of: `string`, `null`

## Request body

_Required._

- `user_ids` (`send_push.user_ids`; any of, optional) — Truememory user ids; resolved to registered devices for the calling app.
  - any of: `array<string>`, `null`
- `tokens` (`send_push.tokens`; any of, optional) — Raw FCM registration tokens, for callers holding their own registry.
  - any of: `array<string>`, `null`
- `topic` (`send_push.topic`; any of, optional)
  - any of: `string`, `null`
- `condition` (`send_push.condition`; any of, optional) — FCM condition expression, e.g. "'a' in topics && 'b' in topics".
  - any of: `string`, `null`
- `title` (`send_push.title`; any of, optional)
  - any of: `string`, `null`
- `body` (`send_push.body`; any of, optional)
  - any of: `string`, `null`
- `image` (`send_push.image`; any of, optional) — Public image URL.
  - any of: `string`, `null`
- `data` (`send_push.data`; any of, optional) — Arbitrary string key/value pairs delivered to the app.
  - any of: `map<string>`, `null`
- `priority` (`send_push.priority`; any of, optional)
  - any of: `string`, `null`
- `ttl_seconds` (`send_push.ttl_seconds`; any of, optional)
  - any of: `integer`, `null`
- `sound` (`send_push.sound`; any of, optional)
  - any of: `string`, `null`
- `badge` (`send_push.badge`; any of, optional)
  - any of: `integer`, `null`
- `dry_run` (`send_push.dry_run`; boolean, optional) — Validate with FCM without delivering to devices.
  - default `false`

## Example request

```json
{
  "user_ids": [
    "string"
  ],
  "tokens": [
    "string"
  ],
  "topic": "string",
  "condition": "string",
  "title": "string",
  "body": "string",
  "image": "string",
  "data": {
    "property1": "string",
    "property2": "string"
  },
  "priority": "normal",
  "ttl_seconds": 2419200,
  "sound": "string",
  "badge": 0,
  "dry_run": false
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url https://truememory-api.mvstg.com/notifications/push \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "user_ids": [
    "string"
  ],
  "tokens": [
    "string"
  ],
  "topic": "string",
  "condition": "string",
  "title": "string",
  "body": "string",
  "image": "string",
  "data": {
    "property1": "string",
    "property2": "string"
  },
  "priority": "normal",
  "ttl_seconds": 2419200,
  "sound": "string",
  "badge": 0,
  "dry_run": false
}
'
```

### TypeScript

```typescript
const url = 'https://truememory-api.mvstg.com/notifications/push';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({
    user_ids: ['string'],
    tokens: ['string'],
    topic: 'string',
    condition: 'string',
    title: 'string',
    body: 'string',
    image: 'string',
    data: {property1: 'string', property2: 'string'},
    priority: 'normal',
    ttl_seconds: 2419200,
    sound: 'string',
    badge: 0,
    dry_run: false
  })
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://truememory-api.mvstg.com/notifications/push"

payload = {
    "user_ids": ["string"],
    "tokens": ["string"],
    "topic": "string",
    "condition": "string",
    "title": "string",
    "body": "string",
    "image": "string",
    "data": {
        "property1": "string",
        "property2": "string"
    },
    "priority": "normal",
    "ttl_seconds": 2419200,
    "sound": "string",
    "badge": 0,
    "dry_run": False
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 200

Successful Response

#### Example

```json
{
  "success_count": 0,
  "failure_count": 0,
  "results": [
    {
      "target": "string",
      "user_id": "string",
      "success": true,
      "message_id": "string",
      "error_code": "string",
      "error": "string",
      "pruned": false
    }
  ],
  "unreachable_user_ids": [
    "string"
  ],
  "pruned_token_count": 0
}
```

- `success_count` (`send_push.response.200.success_count`; integer, required)
- `failure_count` (`send_push.response.200.failure_count`; integer, required)
- `results` (`send_push.response.200.results`; array<object>, required)
  - `target` (`send_push.response.200.results.target`; string, required) — The registration token, topic, or condition sent to.
  - `success` (`send_push.response.200.results.success`; boolean, required)
  - `user_id` (`send_push.response.200.results.user_id`; any of, optional) — Set when the target was resolved from the device registry.
    - any of: `string`, `null`
  - `message_id` (`send_push.response.200.results.message_id`; any of, optional)
    - any of: `string`, `null`
  - `error_code` (`send_push.response.200.results.error_code`; any of, optional) — FCM's error code, uppercased.
    - any of: `string`, `null`
  - `error` (`send_push.response.200.results.error`; any of, optional)
    - any of: `string`, `null`
  - `pruned` (`send_push.response.200.results.pruned`; boolean, optional) — The token was dropped from the registry because FCM reports it dead.
    - default `false`
- `unreachable_user_ids` (`send_push.response.200.unreachable_user_ids`; array<string>, optional) — Requested users with no device registered for this app.
- `pruned_token_count` (`send_push.response.200.pruned_token_count`; integer, optional)
  - default `0`

### 422

Validation Error

#### Example

```json
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string",
      "input": null,
      "ctx": {}
    }
  ]
}
```

- `detail` (`send_push.response.422.detail`; array<object>, optional)
  - `loc` (`send_push.response.422.detail.loc`; array<any of>, required)
    - any of: `string`, `integer`
  - `msg` (`send_push.response.422.detail.msg`; string, required)
  - `type` (`send_push.response.422.detail.type`; string, required)
  - `input` (`send_push.response.422.detail.input`; unknown, optional)
  - `ctx` (`send_push.response.422.detail.ctx`; object, optional)


Source: https://truememory-docs.mvstg.com/api/notifications/push/index.md
