Create a subscription
POST
/user/{userId}/subscription
const url = 'https://client-api.abi.ai/user/abi1234/subscription';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"startDate":"2021-11-17","endDate":"2022-05-31","shouldNotify":true,"productName":"Free trial"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://client-api.abi.ai/user/abi1234/subscription \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "startDate": "2021-11-17", "endDate": "2022-05-31", "shouldNotify": true, "productName": "Free trial" }'Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”userId
required
string
The Abi identifier of the user account.
Example
abi1234Request Bodyrequired
Section titled “Request Bodyrequired”Media typeapplication/json
object
startDate
required
The UTC date on which the subscription becomes active.
string format: date
Example
2021-11-17endDate
The UTC date on which the subscription expires.
string format: date
Example
2022-05-31shouldNotify
Send the configured invitation notification when contact details are available.
boolean
Example
trueproductName
The Abi-provided product identifier for this subscription.
string
Example
Free trialResponses
Section titled “Responses”Subscription created. See the Subscription model for field definitions.
Media typeapplication/json
object
Example
{ "user": { "id": "abi1234", "uniqueId": "123abc789xyz", "userStatus": "activeUser", "firstName": "Jane", "lastName": "Doe", "email": "janedoe@gmail.com", "gender": "female", "phone": "+441234567890", "origin": "gb", "location": "es", "country": "it", "physicianCountry": "es", "language": "en", "dateOfBirth": "1994-10-07", "partnerName": "Abi", "associatedAccounts": 5 }, "subscription": { "subscriptionId": "8910zyx321cba", "userId": "abi1234", "startSubscription": "2021-11-17T00:00:00.000Z", "endSubscription": "2022-05-31T00:00:00.000Z", "active": 1, "createdAt": "2021-11-17T00:00:00.000Z", "canceledAt": null, "shouldNotify": true, "productName": "Free trial", "renewFrom": null }}Request could not be completed.
Media typeapplication/json
object
code
Short machine-readable error code.
string
message
Human-readable explanation of the error.
string
Examplegenerated
{ "code": "example", "message": "example"}Request could not be completed.
Media typeapplication/json
object
code
Short machine-readable error code.
string
message
Human-readable explanation of the error.
string
Examplegenerated
{ "code": "example", "message": "example"}