API Unsubscribe
  • 18 Nov 2024
  • 2 Minutes to read
  • Dark
    Light
  • PDF

API Unsubscribe

  • Dark
    Light
  • PDF

Article summary

Unsubscribe API

Overview

The Unsubscribe API allows clients to unsubscribe an email address from a specific business's mailing list.

Base URL

https://examplebusiness.com/api/v1/Unsubscribe

Endpoint

  • HTTP Method: POST

  • Endpoint: /api/v1/Unsubscribe

Authentication

This API requires an API key, which should be provided in the x-api-key header.

Enabling Access

To enable this API Key follow these steps:

  1. On your BookingTimes website, navigate to Setup > Integrations > External Integrations

  2. Under BookingTimes, click on Enable API Access

  3. Click on Yes, Enable API

  4. Copy your new API Key. This Key will only be visible once, so be sure to save it on your end.

  5. Use this Key while calling the API.

If you have forgotten your API key, you must generate a new one, following these steps:

  1. On your BookingTimes website, navigate to Setup > Integrations > External Integrations

  2. Under BookingTimes, click on Manage Key

  3. Click on Generate New Key

  4. Copy your new API Key. This Key will only be visible once, so be sure to save it on your end.

  5. Use this New Key while calling the API.

To Disable your access, follow the previous guide and on step 3.Click on Disable API Key.

Request Headers

Header

Type

Required

Description

Cache-Control

String

Yes

Set to no-cache.

Content-Type

String

Yes

Must be application/json.

Accept

String

Yes

Expected response format (JSON).

x-api-key

String

Yes

API key provided for authorization.

Request Parameters

The following parameters should be passed in the request:

Parameter

Type

Required

Description

Email

String

Yes

The email address to unsubscribe.

  • Parameter Location: Query String (e.g., ?Email=user@example.com).

Example Request

Request URL:

POST https://examplebusiness.com/api/v1/Unsubscribe?Email=user@example.com

Headers:

codeCache-Control: no-cache
Content-Type: application/json
Accept: application/json
x-api-key: {your_api_key}

Response

The API returns a RestResponse object containing the result of the unsubscribe request.

Success Response

Status Code

Description

200 OK

Unsubscription successful.

Error Responses

If an error occurs, the response will include an appropriate HTTP status code and error details.

Status Code

Description

400 Bad Request

The request is missing required parameters.

401 Unauthorized

The provided API key is missing or invalid.

403 Forbidden

The client does not have permission to access this endpoint.

405 Method Not Allowed

The HTTP method used is not allowed; only POST is accepted.

406 Not Acceptable

The server cannot produce a response matching the acceptable values.

500 Internal Server Error

An error occurred on the server side.

Example Code

Here’s an example of how to call the API in .NET:


Dim rest As New RestClient("https://examplebusiness.com")
Dim request = New RestRequest("Api/v1/Unsubscribe" & "?Email=" &"user@example.com", Method.POST)

request.RequestFormat = DataFormat.Json
request.AddHeader("Cache-Control", "no-cache")
request.AddHeader("Content-Type", "application/json")
request.AddHeader("Accept", "application/json")
request.AddHeader("x-api-key", "your_api_key")

Dim response = rest.Execute(request)

If response.StatusCode = HttpStatusCode.OK Then
    Console.WriteLine("Unsubscription successful.")
Else
    Console.WriteLine("Error: " & response.StatusDescription)
End If

Notes

  • Ensure that you replace {examplebusiness.com} with your actual business website URL.

  • Ensure that you replace {your_api_key} with the latest you have from the Enabling Access step.

Contact and Support

For additional assistance or to report issues with the API, please contact support@bookingtimes.com or visit our Support Page.


Was this article helpful?