Push devices save

Open in

Use the ably push devices save command to register or update a push device.

Synopsis

ably push devices save [options]

Options

--id

The device ID. Required unless --data is provided.

--platform

The device platform. Options are ios, android, and browser.

--form-factor

The device form factor. Options are phone, tablet, desktop, tv, watch, car, embedded, and other.

--transport-type

The push transport type. Options are apns, fcm, and web.

--device-token

The device token for APNs or FCM. Required when transport type is apns or fcm.

--target-url

The target URL for web push. Required when transport type is web.

--p256dh-key

The P-256 Diffie-Hellman key for web push. Required when transport type is web.

--auth-secret

The authentication secret for web push. Required when transport type is web.

--client-id

The client ID to associate with the device.

--metadata

Device metadata as a JSON string.

--data

Full device registration JSON, or a file path prefixed with @.

--json

Output results as compact JSON. Mutually exclusive with --pretty-json.

--pretty-json

Output results in formatted JSON. Mutually exclusive with --json.

--verbose | -v

Enable verbose logging. Can be combined with --json or --pretty-json.

Examples

Register an iOS device:

ably push devices save --id "device-001" --platform ios --form-factor phone --transport-type apns --device-token "token123" --client-id "user456"

Register a web push device:

ably push devices save --platform browser --form-factor desktop --transport-type web --target-url "https://example.com/push" --p256dh-key "key123" --auth-secret "secret456"

Register a device from a JSON file:

ably push devices save --data @device.json

Register a device using inline JSON data:

ably push devices save --data '{"id":"device-123","platform":"ios","formFactor":"phone","push":{"recipient":{"transportType":"apns","deviceToken":"token123"}}}'

Register a device and output the result in JSON format:

ably push devices save --id device-123 --platform ios --form-factor phone --transport-type apns --device-token token123 --json

See also

  • Push — Explore all ably push commands.
  • CLI reference — Full list of available commands.