Upsert B2C subscription
On this page
GraphQL endpoint: /user
Creates or updates a B2C subscription directly, without going through the request/response flow. The subscription type (EMAIL, SMS, VOICE) determines the required contact reference: emailId for EMAIL, telephoneNumberId for SMS/VOICE. Optionally accepts an expiration date and a notification time window. If a subscription already exists for this company/type combination it is updated; otherwise a new one is created.
Query
mutation (
$companyId: ID!
$type: B2cSubscriptionType!
$emailId: ID
$telephoneNumberId: ID
$subscriptionTopicIds: [ID!]!
$expirationDate: Date
$notificationStartTime: Time
$notificationEndTime: Time
) {
upsertB2cSubscription (
companyId: $companyId
type: $type
emailId: $emailId
telephoneNumberId: $telephoneNumberId
subscriptionTopicIds: $subscriptionTopicIds
expirationDate: $expirationDate
notificationStartTime: $notificationStartTime
notificationEndTime: $notificationEndTime
) {
... on B2cEmailSubscription {
id
insertedAt
updatedAt
type
subscriptionTopics
expirationDate
notificationStartTime
notificationEndTime
email
company {
id
}
user {
id
}
}
... on B2cSmsSubscription {
id
insertedAt
updatedAt
type
subscriptionTopics
expirationDate
notificationStartTime
notificationEndTime
telephoneNumber
company {
id
}
user {
id
}
}
... on B2cVoiceSubscription {
id
insertedAt
updatedAt
type
subscriptionTopics
expirationDate
notificationStartTime
notificationEndTime
telephoneNumber
company {
id
}
user {
id
}
}
}
}
Variables
{
"companyId": "00000000-0000-4000-8000-000000000001",
"emailId": "00000000-0000-4000-8000-000000000004",
"expirationDate": "2030-12-31",
"notificationEndTime": "16:00:00",
"notificationStartTime": "08:00:00",
"subscriptionTopicIds": [
"00000000-0000-4000-8000-000000000005",
"00000000-0000-4000-8000-000000000006"
],
"type": "EMAIL"
}
Response
{
"data": {
"upsertB2cSubscription": {
"company": {
"id": "00000000-0000-4000-8000-000000000001"
},
"email": "test1@email.com",
"expirationDate": "2030-12-31",
"id": "00000000-0000-4000-8000-000000000002",
"insertedAt": "2026-01-15T09:00:00.000000",
"notificationEndTime": "16:00:00",
"notificationStartTime": "08:00:00",
"subscriptionTopics": [
"topic_2",
"topic_3"
],
"type": "EMAIL",
"updatedAt": "2026-01-15T09:00:00.000000",
"user": {
"id": "00000000-0000-4000-8000-000000000003"
}
}
}
}