VoidhashDocs
DevelopersHelp centerGuidesAPI reference
Dashboard
Essentials
API overview
Authentication
Event capture
Push device API
Webhooks
Webhook delivery
Webhook events
Projects & keys
Projects
API keys
Audit log
Customers & access
Persons
Products
Perks
Sandbox
Paywalls
Paywalls
Paywall locations
Components
Component registry
Assets
Experiments & flags
Experiments
Feature flags
Analytics & events
Analytics
Analytics alerts
Events
Ingest policy
VoidQL
Tracking domains
Ads
Ads
Ad accounts
Meta measurement
Payments & stores
Payment providers
Payment provider products
Purchase history imports
Payment sources
Webhooks & notifications
Webhooks
Push notifications
Push configurations
Automations
Organization & team
Organizations
Members
Invitations
Billing
Your account
Profile
Session
Notices
Connected apps
Terms of Service
Developer tools
Schema
SDK

Push device API

The client API endpoints that register, refresh and unregister a device's push token, with their headers, fields and responses.

Your app registers each device's push token with the client API, so Voidhash can send push notifications to it. Register devices for push has the app code for Swift, Kotlin and React Native; this page is the reference behind it.

EndpointBody
POST /api/v1/sdk/push-devices/registerThe device; see Register a device.
POST /api/v1/sdk/push-devices/refreshpushDeviceTokenId and the new platformToken.
POST /api/v1/sdk/push-devices/unregisterpushDeviceTokenId.

The examples target Voidhash Cloud; a self-hosted install uses its own API origin.

Headers

The endpoints take the publishable key and the same headers the SDKs send. Every header is required except x-distinct-id-encoding. A request missing one fails with 400 and a body whose _tag is Api/SdkValidationError, with a message naming the problem.

HeaderValue
x-publishable-keyThe project's publishable key: vh_pk_..., or vh_pk_test_... in debug builds.
x-distinct-idThe person's distinct ID, the one the SDK uses.
x-client-bundle-idThe app's bundle ID on iOS or package name on Android.
x-platformios or android.
x-platform-flavornative in an app.
x-sdkThe Voidhash SDK your app embeds: ios, android or react-native.
x-sdk-versionThat SDK's version, such as 0.0.1-alpha.1.
x-is-debug-buildtrue in a debug build, otherwise false.
x-is-backgroundedtrue when the app sends the request from the background, otherwise false.
x-observer-modetrue when the SDK runs in observer mode, otherwise false.
x-distinct-id-encodingOptional. percent when x-distinct-id is percent-encoded because the ID isn't printable ASCII.

The anonymous IDs the SDK creates never need percent-encoding.

Register a device

curl https://api.voidhash.com/api/v1/sdk/push-devices/register \
  -H "x-publishable-key: vh_pk_..." \
  -H "x-distinct-id: user_123" \
  -H "x-client-bundle-id: com.example.app" \
  -H "x-platform: ios" \
  -H "x-platform-flavor: native" \
  -H "x-sdk: ios" \
  -H "x-sdk-version: 0.0.1-alpha.1" \
  -H "x-is-debug-build: false" \
  -H "x-is-backgrounded: false" \
  -H "x-observer-mode: false" \
  -H "content-type: application/json" \
  -d '{
    "platform": "ios",
    "provider": "apns",
    "platformToken": "<device token as hex>",
    "bundleId": "com.example.app",
    "environment": "production"
  }'
FieldDescription
platformios or android.
providerapns for an APNs device token, fcm for an FCM registration token.
platformTokenThe token from the platform. For APNs, the device token as a hex string.
bundleIdRequired for apns.
environmentRequired for apns: sandbox for builds run from Xcode, production for TestFlight and the App Store.
previousPushDeviceTokenIdOptional. The ID from an earlier install or token, so Voidhash drops that registration.

The response holds a pushDeviceTokenId; keep it on the device. Registering the same token again returns the same ID. A device belongs to the person who registered it last: registering the token under another distinct ID moves it.

Refresh and unregister

When the platform rotates the token, call refresh with pushDeviceTokenId and the new platformToken. When the person signs out, call unregister with pushDeviceTokenId before the SDK signs out. Both send the same headers as register. They answer 404 for a device that another distinct ID registered, which is why unregistering after signOut() fails.

When APNs or FCM reports that a token no longer exists, Voidhash stops sending to it.

Responses

Registration never needs to block the UI or a purchase. Run it in the background and treat a failure as "try again next launch".

ResponseMeaningWhat to do
Network error, 500Voidhash couldn't be reached or failed.Retry on the next launch or token change.
400A header or body field is missing or invalid, such as apns without bundleId and environment.Fix the request; retrying won't help.
401The publishable key is wrong.Check the key and its environment.
403Push notifications aren't turned on for your team.Ask us to turn them on; don't retry.
404The device isn't registered to this distinct ID.On unregister, treat it as done.

Next steps

  • Register devices for push: the app code for each platform.
  • Push notifications: connect APNs or FCM, send and follow delivery.
  • People and identity: how distinct IDs map devices to people.

Something wrong or missing on this page? Tell us by email or on Discord.

PreviousCapture a batch of eventsNextWebhook delivery

On this page

HeadersRegister a deviceRefresh and unregisterResponsesNext steps