API Opt-in

Programmatically opt-in a phone number as subscriber via API

Creating an API Opt-in Campaign

Checkout List Building - User Guide  to know more about creating a campaign

Getting a Campaign ID

When creating or editing an API opt-in campaign, the CampaignId to be provided in the API request can be found in the URL after "list-building".

Note: Double Opt-in is required for compliance.

Implementing API Opt-in 

Replace <CAMPAIGN_ID> with your API-specific Campaign ID

Phone numbers must be formatted using a '+' and country code

e.g., +16175551212 (E.164 format)

API Details

Request

POST /api/events/SubscribeNumber HTTP/1.1
Host: vyg.mobi
Accept: application/json
Content-Type: application/json

{
"phoneIn": "+15134XXXXXX‬",
"campaignId": "<CAMPAIGN_ID>"
}

Response

{ 
subscriberId: 99999,
state: "Subscribed",
}

Examples

cURL

curl --location --request POST 'https://vyg.mobi/api/events/SubscribeNumber' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data-raw '{ "phoneIn": "+15134XXXXXX‬","campaignId": "<CAMPAIGN_ID>" }'

JavaScript

const data = {
phoneIn: "+15134XXXXXX‬",
campaignId: "<CAMPAIGN_ID>"
};

fetch('https://vyg.mobi/api/events/SubscribeNumber', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => {
console.log('Success:', data);
// Success: { subscriberId: 00000, state: "Subscribed" }
})
.catch((error) => {
console.error('Error:', error);
// Error: "Bad Request: Must be a US number starting with +1"
});

Note: CORS-supported to allow all origins.