Skip to content

Save a Web Push subscription

POST
/me/push/subscriptions
curl --request POST \
--url https://example.com/api/v1/me/push/subscriptions \
--header 'Content-Type: application/json' \
--cookie better-auth.session_token=<better-auth.session_token> \
--data '{ "endpoint": "example", "keys": { "auth": "example", "p256dh": "example" }, "label": "example" }'

Registers or updates a browser Web Push subscription for the signed-in user. Only endpoints hosted by supported browser push services are accepted.

Requires a signed-in browser session; API tokens are rejected with 403.

Media typeapplication/json
object
endpoint
required

Push service endpoint URL returned by PushManager.subscribe().

string
<= 2048 characters
keys
required

Client encryption keys from PushSubscription.toJSON().

object
auth
required

Base64url-encoded 16-byte Web Push auth secret.

string
p256dh
required

Base64url-encoded 65-byte uncompressed P-256 client public key.

string
label

Optional browser or device label.

string
>= 1 characters <= 80 characters

Example generated

{
"endpoint": "example",
"keys": {
"auth": "example",
"p256dh": "example"
},
"label": "example"
}

Push subscription saved

Media typeapplication/json

Simple acknowledgement response.

object
ok
required

Example

{
"ok": true
}

Invalid request input or rule violation.

Media typeapplication/json

Error returned when request input fails schema validation or violates a domain rule.

object
code
required
string
Allowed values: BAD_REQUEST
data
object
issues
required

Field-level validation failures, present when schema validation fails.

Array<object>
object
message
required
string
path
required

Dot-separated field path.

string
message
required

Human-readable error explanation.

string

Example

{
"code": "BAD_REQUEST"
}

Authentication required or credentials invalid.

Media typeapplication/json

Standard REST error envelope.

object
code
required

Machine-readable error code.

string
data

Optional structured error details.

message
required

Human-readable error explanation.

string

Example generated

{
"code": "example",
"data": "example",
"message": "example"
}

Insufficient role, bucket grant, or token scope.

Media typeapplication/json

Standard REST error envelope.

object
code
required

Machine-readable error code.

string
data

Optional structured error details.

message
required

Human-readable error explanation.

string

Example generated

{
"code": "example",
"data": "example",
"message": "example"
}

Unexpected server error. Quote data.requestId when you report it.

Media typeapplication/json

Error returned when Sendcrate or one of its providers fails (5xx).

object
code
required
string
Allowed values: INTERNAL_SERVER_ERROR PROVIDER_FAILED
data
object
debug

Error chain with stack traces. Present only when the server runs in development mode.

Array
requestId

Request reference to quote when you report the error.

string
message
required

Human-readable error explanation.

string

Example

{
"code": "INTERNAL_SERVER_ERROR"
}