Developer API

The Developer API is an interface for integrating third-party applications with our unique image processing service.

The API can be used to:
- create template (POST Template)
- get template detail (GET Template)
- get a list of available templates (GET Templates)
- (updated) add an image to the processing queue (POST Image)
- remove an image from the processing queue (DELETE Image)
- get an image status (GET Image Status)
- (updated) get the images list (GET Images List)
- count number of images (GET Count Images)
- (new) get the productid-s list (GET ProductId-s List)
- reject a processed image (REJECT Image)
- create new contact (POST Contact)
- update contact (PUT Contact)
- get contact information (GET Contact)
- get invoices (GET Invoices)
- get notification about processed image (Webhook)

When you add images to the processing queue you can define a URL for the Webhook. The Webhook is a simple ''image-has-been-processed''-notification via HTTP POST containing the URL to download image.

 

Getting Started

When connecting to Remove The Background™ you need an API Key. If you don't already have an API Key, please sign up for an account (the API Key can be found under Account Settings).

The API Key is used to identify both a customer (ContactAPIkey) and a developer (DeveloperAPIkey). For testing purposes you can use your API Key as both ContactAPIkey and DeveloperAPIkey. The DeveloperAPIkey is used for Resellers and Developer Partners to receive discounts when placing orders.

 

SOAP API

This API is also available in a SOAP version. Click here to go to SOAP service description, or you may like to have HTTPS SOAP API version.

 

POST Template

Create new template. A template is a set of instructions on how the images should be processed.
POST payload has the parameters as JSON collection
URL: http://api.removethebackground.com/REST.svc/Template/
OR: https://api.removethebackground.com/REST.svc/Template/
Method: POST
Requires Authentication: false

Parameter Required Details
contactEmail true  
contactAPIkey true  
templateName true Template name. Accept values: A-Z, a-z, 0-9, () and space
templateOutputFormat true Image output format. Accept values: JPG, JPEG, TIF, TIFF, PNG, PSD
deliveryTimeInHour true Delivery time. Accept values: 168, 72, 24
backgroundType true Background type
0: No background removal
1: Background filled with color; backgroundColor will be required.
2: Transparent background; fileType cannot be JPG/JPEG.
3: Vertical gradient filled background; backgroundColor and backgroundVerticalGradientColor will be required.
backgroundColor false Hexadecimal number in [000000, FFFFFF]
backgroundVerticalGradientColor false Hexadecimal number in [000000, FFFFFF]
resizeType false Resize type
0: Keep original canvas size (Default)
1: Canvas aspect ratio
2: Fixed width / height
3: Min max only
resizeUnit false Resize unit, will be ignore if Resize type is 'Canvas aspect ratio'
0: pixel (Default)
1: milimet
2: inch
resizeHeight false Image height after resize
resizeWidth false Image width after resize
resizeMinSize false Image minimum size for both dimensions
resizeMaxSize false Image maximum size for both dimensions
marginType false Margin type
0: Margins not set (Default)
1: Margins in percent
2: Margins in pixels
marginTop false Top margin
marginBottom false Bottom margin
marginLeft false Left margin
marginRight false Right margin
marginVerticalAlignment false How to vertically align if object does not fill canvas
1: Top
2: Center (Default)
3: Bottom
shadowType false Shadow type
0: No shadow (default)
1: Keep original shadow
2: Drop shadow
isKeptMannequin false Keep the Mannequin or not, accept values: "true", "false"
isKeptModel false Keep the Model or not, accept values: "true", "false"

Example of payload POST:

{
    "contactEmail": "john @ removethebackground.com",
    "contactAPIkey": "44979dfe-5aa7-44ea-b3dd-7fae33bc37e9",
    "templateName":"My_First_Template",    
    "templateOutputFormat":"JPG",    
    "deliveryTimeInHour":"72",    
    "backgroundType":"1",    
    "backgroundColor":"FFFFFF",    
    "backgroundVerticalGradientColor":"",    
    "resizeType":"1",    
    "resizeUnit":"",    
    "resizeHeight":"4",    
    "resizeWidth":"3",    
    "resizeMinSize":"",    
    "resizeMaxSize":"",    
    "marginType":"2",    
    "marginTop":"10",    
    "marginBottom":"10",    
    "marginLeft":"15",    
    "marginRight":"15",    
    "marginVerticalAlignment":"",    
    "shadowType":""
    "isKeptMannequin":"false"
    "isKeptModel":"false"
}

XML Response:

<NewTemplateResponse>
    <Message>Success</Message>
    <ErrorCode>NoError</ErrorCode>
    <TemplateId>2017982</TemplateId>
    <Price>
        <Amount>0.95</Amount>
        <Currency>USD</Currency>
        <CurrencyId>1</CurrencyId>
    </Price>
</NewTemplateResponse>

Test Form: POST Template

Enter your information in the form below and get the server response.

contactEmail:
contactAPIkey:
templateName:
templateOutputFormat:
deliveryTimeInHour:
backgroundType:
backgroundColor:
backgroundVerticalGradientColor:
resizeType:
resizeUnit:
resizeHeight:
resizeWidth:
resizeMinSize:
resizeMaxSize:
marginType:
marginTop:
marginBottom:
marginLeft:
marginRight:
marginVerticalAlignment:
shadowType:
isKeptMannequin:
isKeptModel:
JSON Data:
Server response:

GET Template

Retrieves a template detail.
URL: http://api.removethebackground.com/REST.svc/Template/{templateId}/
OR: https://api.removethebackground.com/REST.svc/Template/{templateId}/
Method: GET
Requires Authentication: false

Parameter Required
contactEmail true
contactAPIkey true
templateId true

XML Response:

<TemplateSpecResponse>
    <ErrorCode>NoError</ErrorCode>
    <Message>Success</Message>
    <Template>
        <BackgroundColor>ffffff</BackgroundColor>
        <BackgroundType>1</BackgroundType>
        <BackgroundVerticalGradientColor/>
        <CallbackFtp i:nil="true"/>
        <CallbackUrl/>
        <CreatedDate>2013-01-02</CreatedDate>
        <DeliveryTimeInHours>168</DeliveryTimeInHours>
        <Id>2018588</Id>
        <IsDeleted>false</IsDeleted>
        <MarginBottom>10</MarginBottom>
        <MarginLeft>10</MarginLeft>
        <MarginRight>10</MarginRight>
        <MarginTop>10</MarginTop>
        <MarginType>2</MarginType>
        <ModifiedDate>2013-01-02</ModifiedDate>
        <Name>Amazon Default Template</Name>
        <OutputFormat>JPG</OutputFormat>
        <Price>
            <a:Amount>0.95</a:Amount>
            <a:Currency>USD</a:Currency>
            <a:CurrencyId>1</a:CurrencyId>
        </Price>
        <ResizeHeight>0</ResizeHeight>
        <ResizeMaxSize>3000</ResizeMaxSize>
        <ResizeMinSize>1000</ResizeMinSize>
        <ResizeType>5</ResizeType>
        <ResizeUnit>0</ResizeUnit>
        <ResizeWidth>0</ResizeWidth>
        <ShadowType i:nil="true"/>
        <VerticalAlignment i:nil="true"/>
    </Template>
</TemplateSpecResponse>

Test Form: GET Template

Enter your information in the form below and get the server response.

contactEmail:
contactAPIkey:
templateId:

GET Templates

Retrieves a list of templates.
URL: http://api.removethebackground.com/REST.svc/Templates/
OR: https://api.removethebackground.com/REST.svc/Templates/
Method: GET
Requires Authentication: false

Parameter Required
contactEmail true
contactAPIkey true

XML Response:

  <TemplatesResponse>
    <ErrorCode>NoError</ErrorCode>
    <Message/>
    <Templates>
      <Template>
        <Prices>
          <Price>
            <Amount>0.95</Amount>
            <Currency>USD</Currency>
            <CurrencyId>1</CurrencyId>
          </Price>
        </Prices>
        <TemplateId>2000045</TemplateId>
        <TemplateName>T-shirts</TemplateName>
        <IsCombinedImages>false</IsCombinedImages>
      </Template>
    </Templates>
  </TemplatesResponse>

Test Form: GET Templates

Enter your information in the form below and get the server response.

contactEmail:
contactAPIkey:

POST Image

POST payload has the parameters as JSON collection
URL: http://api.removethebackground.com/REST.svc/Image/
OR: https://api.removethebackground.com/REST.svc/Image/
Method: POST
Requires Authentication: false

Parameter Required Details
contactEmail true  
contactAPIkey true  
developerAPIkey false Can be the same as contactAPIkey
templateId false Use GetTemplates to find templateID
imageURL true The source URL of image
imageURL2 false The source URL of 2nd image (combining images)
imageURL3 false The source URL of 3rd image (combining images)
imageURL4 false The source URL of 4th image (combining images)
imageURL5 false The source URL of 5th image (combining images)
imageRequestedDeliveryTimeInHours false Overwrites template delivery time.
imageCallbackURL false Webhook callback URL when image is processed
customerImageId false ImageID at the customer side. You can use it as image identity
productId false All images with the same ProductID will be collected into a single package, and we can take care the consistent quality of all images in this package.

Example of payload POST:

    {
        "contactEmail": "john @ removethebackground.com",
        "contactAPIkey": "44979dfe-5aa7-44ea-b3dd-7fae33bc37e9",
        "developerAPIkey": "44979dfe-5aa7-44ea-b3dd-7fae33bc37e9",
        "templateId": "2000045",
        "imageURL": "http://www.mydomain.com/myimage.jpg",
        "imageURL2": "",
        "imageURL3": "",
        "imageURL4": "",
        "imageURL5": "",
        "imageRequestedDeliveryTimeInHours": "24",
        "imageCallbackURL": "http://www.mydomain.com/callback-url.php",
        "customerImageId": "12345",
        "productId": "Crying Baby Tee 066"
    }

XML Response:

  <AddImageResponse>
    <ErrorCode>NoError</ErrorCode>
    <Message/>
    <ImageTicket>a37a1f55-7cd4-4474-db19-ac03e85538a7</ImageTicket>
    <IsTrial>false</IsTrial>
    <CustomerImageId>12345</CustomerImageId>
  </AddImageResponse>

Test Form: POST Image

Enter your information in the form below and get the server response.

contactEmail:
contactAPIkey:
developerAPIkey:
templateId:
imageURL:
imageURL2:
imageURL3:
imageURL4:
imageURL5:
imageRequestedDeliveryTimeInHours:
imageCallbackURL:
customerImageId:
productId:
JSON Data:
Server response:

DELETE Image

DELETE payload has the parameters as JSON collection. Cannot delete an in-production image.
URL: http://api.removethebackground.com/REST.svc/Image/{imageTicket}/
OR: https://api.removethebackground.com/REST.svc/Image/{imageTicket}/
Method: DELETE
Requires Authentication: false

Parameter Required
contactEmail true
contactAPIkey true
imageTicket true. If you gonna using customerImageId, set it is "nonticket"
customerImageId false

Example of payload DELETE:

          {
            "contactEmail": "john @ removethebackground.com",
            "contactAPIkey": "44979dfe-5aa7-44ea-b3dd-7fae33bc37e9",
            "imageTicket": "8de624ab-593b-409d-8324-eb4890c4b867"
          }
          {
            "contactEmail": "john @ removethebackground.com",
            "contactAPIkey": "44979dfe-5aa7-44ea-b3dd-7fae33bc37e9",
            "imageTicket": "nonticket",
            "customerImageId": "12345"
          }

XML Response:

  <DeleteImageResponse>
    <ErrorCode>NoError</ErrorCode>
    <Message>Image was deleted</Message>
  </DeleteImageResponse>

Test Form: DELETE Image

Enter your information in the form below and get the server response.

contactEmail:
contactAPIkey:
imageTicket:
customerImageId:
JSON Data:
Server response:

GET Status

Get the status of image production.
URL: http://api.removethebackground.com/REST.svc/Image/{imageTicket}/
OR: https://api.removethebackground.com/REST.svc/Image/{imageTicket}/
Method: GET
Requires Authentication: false

Parameter Required
contactEmail true
contactAPIkey true
imageTicket true. If you gonna using customerImageId, set it is "nonticket"
customerImageId false

XML Response:

  <ImageStatusResponse>
    <ErrorCode>NoError</ErrorCode>
    <Message/>
    <ImageStatus>
      <FinalImagesURL>
        <string>1000003/2000000/final/myimage.jpg</string>
      </FinalImagesURL>
      <ImageTicket>33979dfe-5ea7-44ea-b3dd-7fde33bc37e9</ImageTicket>
      <StatusId>80</StatusId>
      <StatusName>Delivered</StatusName>
      <IsPaid>false</IsPaid>
      <ThumbnailImageURL>1000003/2000000/thumbnail/myimage.jpg</ThumbnailImageURL>
      <CustomerImageId />
      <ProductId />
    </ImageStatus>
  </ImageStatusResponse>
    

Test Form: GET Status

Enter your information in the form below and get the server response.

contactEmail:
contactAPIkey:
imageTicket:
customerImageId:

GET Images List

Get a list of images.
URL: http://api.removethebackground.com/REST.svc/Images/
OR: https://api.removethebackground.com/REST.svc/Images/
Method: GET
Requires Authentication: false

Parameter Required Detail
contactEmail true  
contactAPIkey true  
imageStatus false The image status. Refer to table "Image status explanation" for more detailed.
excludeImageStatus false The image status to exclude. Refer to table "Image status explanation" for more detailed.
productId false The ProductID. See POST Image for more detailed.
fromDate false Image created date, lower bound included.
toDate false Image created date, upper bound included.
page false The page number. Default value is 1.
imagesPerPage false Number of images per page. Default value is 10, maximum value is 100.
sortBy false The field name that result will be sort by. Accept values: "id", "date", "status".
isDescending false The sort order is descending or not, accept values: "true", "false".

Image status explanation

Image status Detail
0Deleted by user
10New images
12New images - download failed
20Deprecated! New images - waiting for payment
30Ready for production
40Returned for production (by you)
60In production
62Assigned to editor
64Downloaded by editor
66Quality Assurance
70Production finished - ready for download
72Production finished - 1st delivery attempt failed
74Production finished - 2nd delivery attempt failed
76Production finished - 3rd delivery attempt failed
78Production finished - Delivery failed
80Delivered
90Rejected by Remove The Background
95Awaiting your reply
100Closed
999Deleted by cleanup service

XML Response:

<ImagesListResponse>
  <ErrorCode>NoError</ErrorCode>
  <Message/>
  <Images>
    <ImageStatus>
      <FinalImagesURL>
        <string>1000003/2000000/final/myimage1.jpg</string>
      </FinalImagesURL>
      <ImageTicket>0da2bbe9-4cf4-4c16-8e46-52048836a01b</ImageTicket>
      <StatusId>70</StatusId>
      <StatusName>Production Finished</StatusName>
      <IsPaid>false</IsPaid>
      <ThumbnailImageURL>1000003/2000000/thumbnail/myimage1.jpg</ThumbnailImageURL>
      <CustomerImageId />
      <ProductId />
    </ImageStatus>
    <ImageStatus>
      <FinalImagesURL>
        <string>1000003/2000000/final/myimage2.jpg</string>
      </FinalImagesURL>
      <ImageTicket>fb4751e1-4475-4bf8-a21f-1c0d8b1bb52d</ImageTicket>
      <StatusId>80</StatusId>
      <StatusName>Delivered</StatusName>
      <IsPaid>false</IsPaid>
      <ThumbnailImageURL>1000003/2000000/thumbnail/myimage2.jpg</ThumbnailImageURL>
      <CustomerImageId />
      <ProductId />
    </ImageStatus>
  </Images>
</ImagesListResponse>


Test Form: GET Images List

Enter your information in the form below and get the server response.

contactEmail:
contactAPIkey:
imageStatus:
fromDate:
toDate:
page:
imagesPerPage:
excludeImageStatus:
sortBy:
isDescending:

GET Count Images

Count number of images.
URL: http://api.removethebackground.com/REST.svc/Images/Count/
OR: https://api.removethebackground.com/REST.svc/Images/Count/
Method: GET
Requires Authentication: false

Parameter Required Detail
contactEmail true  
contactAPIkey true  
imageStatus false The image status. Refer to table "Image status explanation" for more detailed.
fromDate false Image created date, lower bound included.
toDate false Image created date, upper bound included.

XML Response:

<ImagesCountResponse>
  <ErrorCode>NoError</ErrorCode>
  <Message/>
  <ImagesCount>315</ImagesCount>
</ImagesCountResponse>


Test Form: COUNT Images

Enter your information in the form below and get the server response.

contactEmail:
contactAPIkey:
imageStatus:
fromDate:
toDate:

GET ProductId-s List

Get a list of ProductId-s.
URL: http://api.removethebackground.com/REST.svc/ProductIds/
OR: https://api.removethebackground.com/REST.svc/ProductIds/
Method: GET
Requires Authentication: false

Parameter Required Detail
contactEmail true  
contactAPIkey true  
page false The page number. Default value is 1.
productIdsPerPage false Number of productId-s per page. Default value is 10, maximum value is 100.

XML Response:

<ProductIdsListResponse>
    <Message/>
    <ErrorCode>NoError</ErrorCode>
    <ProductIds>
        <ProductIdStatistic>
            <ProductId>test product 01</ProductId>
            <DoneCount>102</DoneCount>
            <TodoCount>5</TodoCount>
        </ProductIdStatistic>
        <ProductIdStatistic>
            <ProductId>test product 02</ProductId>
            <DoneCount>27</DoneCount>
            <TodoCount>0</TodoCount>
        </ProductIdStatistic>
    </ProductIds>
</ProductIdsListResponse>


Test Form: GET ProductId-s List

Enter your information in the form below and get the server response.

contactEmail:
contactAPIkey:
page:
productIdsPerPage:

REJECT Image

REJECT payload has the parameters as JSON collection. Cannot reject a not yet finished image.
URL: http://api.removethebackground.com/REST.svc/Image/Reject/{imageTicket}/
OR: https://api.removethebackground.com/REST.svc/Image/Reject/{imageTicket}/
Method: PUT
Requires Authentication: false

Parameter Required
contactEmail true
contactAPIkey true
imageTicket true. If you gonna using customerImageId, set it is "nonticket"
customerImageId false
comment false

Example of payload REJECT:

          {
            "contactEmail": "john @ removethebackground.com",
            "contactAPIkey": "44979dfe-5aa7-44ea-b3dd-7fae33bc37e9",
            "imageTicket": "8de624ab-593b-409d-8324-eb4890c4b867",
            "comment": "Free text comment"
          }
          {
            "contactEmail": "john @ removethebackground.com",
            "contactAPIkey": "44979dfe-5aa7-44ea-b3dd-7fae33bc37e9",
            "imageTicket": "nonticket",
            "customerImageId": "12345"
            "comment": "Free text comment"
          }

XML Response:

  <RejectImageResponse >
    <ErrorCode>NoError</ErrorCode>
    <Message>Image was rejected.</Message>
  </RejectImageResponse >

Test Form: REJECT Image

Enter your information in the form below and get the server response.

contactEmail:
contactAPIkey:
imageTicket:
customerImageId:
comment:
JSON Data:
Server response:

POST Contact

POST payload has the parameters as JSON collection
URL: http://api.removethebackground.com/REST.svc/Contact/
OR: https://api.removethebackground.com/REST.svc/Contact/
Method: POST
Requires Authentication: false

Parameter Required Details
developerEmail true  
developerAPIkey true  
contactEmail true Email of the new contact
contactName true Name of the new contact
countryCode true The ISO 3166-1 alpha-2 two-letter country code
contactAddress1 false  
contactAddress2 false  
contactPhone false  
contactCity false  
contactState false  
contactZipCode false  

Example of payload POST:

    {
        "developerEmail":"john @ removethebackground.com",
        "developerAPIkey":"44979dfe-5aa7-44ea-b3dd-7fae33bc37e9",
        "contactEmail":"my_new_customer @ domain.com",
        "contactName":"My First Customer",
        "countryCode":"US",
        "contactAddress1":"",
        "contactAddress2":"",
        "contactPhone":"",
        "contactCity":"",
        "contactState":"",
        "contactZipCode":""
    }

XML Response:

<NewContactResponse>
    <ErrorCode>NoError</ErrorCode>
    <Message>Success</Message>
    <ContactAPIkey>5ea1a104-f31f-4de1-b7f8-e4444e38e32a</ContactAPIkey>
    <ContactEmail>my_new_customer @ domain.com</ContactEmail>
</NewContactResponse>

Test Form: POST Contact

Enter your information in the form below and get the server response.

developerEmail:
developerAPIkey:
contactEmail:
contactName:
countryCode:
contactAddress1:
contactAddress2:
contactPhone:
contactCity:
contactState:
contactZipCode:
JSON Data:
Server response:

GET Contact

Retrieves your contact information, include email, contact person, credit line and account balance.
URL: http://api.removethebackground.com/REST.svc/Contact/
OR: https://api.removethebackground.com/REST.svc/Contact/
Method: GET
Requires Authentication: false

Parameter Required
contactEmail true
contactAPIkey true

XML Response:

  <ContactResponse>
    <ErrorCode>NoError</ErrorCode>
    <Message/>
    <Contact>
      <ContactAccountBalance>
        <Amount>81.05</Amount>
        <Currency>USD</Currency>
        <CurrencyId>1</CurrencyId>
      </ContactAccountBalance>
      <ContactCompany>Remove The Background</ContactCompany>
      <ContactDaysOfCredit>10000</ContactDaysOfCredit>
      <ContactEmail>john @ removethebackground.com</ContactEmail>
      <ContactPerson>John</ContactPerson>
      <NumberOfTrialImages>3</NumberOfTrialImages>
    </Contact>
  </ContactResponse>

Test Form: GET Contact

Enter your information in the form below and get the server response.

contactEmail:
contactAPIkey:

GET Invoices

Retrieves your invoices list.
URL: http://api.removethebackground.com/REST.svc/Invoices/
OR: https://api.removethebackground.com/REST.svc/Invoices/
Method: GET
Requires Authentication: false

Parameter Required Detail
contactEmail true  
contactAPIkey true  
fromDate false Invoice created date, lower bound included.
toDate false Invoice created date, upper bound included.
page false The page number. Default value is 1. Max 50 invoices per page.
returnUrl false The URL where customer will be redirected after finish payment

XML Response:

<InvoiceListResponse>
  <Message/>
  <ErrorCode>NoError</ErrorCode>
  <Invoices>
    <Invoice>
      <InvoiceId>INV-1315</InvoiceId>
      <CreatedDate>2012-12-31</CreatedDate>
      <AmountDue>0.00</AmountDue>
      <IsPaid>true</IsPaid>
      <PaymentUrl />
      <InvoiceUrl>http://www.removethebackground.com/DownloadInvoice?invoiceNumber=INV-1315</InvoiceUrl>
    </Invoice>
    <Invoice>
      <InvoiceId>INV-1289</InvoiceId>
      <CreatedDate>2012-12-26</CreatedDate>
      <AmountDue>105.00</AmountDue>
      <IsPaid>false</IsPaid>
      <PaymentUrl>http://www.removethebackground.com/transactions.aspx?key=1234567890&returnUrl=http://test.com/testurl</PaymentUrl>
      <InvoiceUrl>http://www.removethebackground.com/DownloadInvoice?invoiceNumber=INV-1289</InvoiceUrl>
    </Invoice>
  </Invoices>
</InvoiceListResponse>

Test Form: GET Invoices

Enter your information in the form below and get the server response.

contactEmail:
contactAPIkey:
fromDate:
toDate:
page:
returnUrl:

Webhook

The Remove The Background Webhook will notify you when the image has been processed. The Webhook will POST data to the Image Callback URL specified and expects a 200 HTTP status code. The Webhook will try to deliver the image 4 times with different time intervals:
First try: Right after the image finished
Second try: +5 minutes later
Third try: +1 hour later
Fourth try: +5 hours later
The ImageCallbackURL has higher priority than TemplateCallbackURL. If image has no ImageCallbackURL then we will use TemplateCallbackURL.
URL: As specified
Method: POST
Requires Authentication: false

Parameter Required Details
imageTicket true The ticketID of the processed image
processedImageURL true The URL to download image from remote server

Test form: Webhook

Here you can make a test request to your call back page.

contactAPIkey:
Call Back URL:

Verify Webhook

Our webhooks can be verified that they came from RemoveTheBackground by calculating a digital signature.

Along with the data sent in the request, each Webhook request includes
- a HTTP_X_RTB_PARTNER_HMAC_SHA256 header, encoded using partner application secret code. Log in into our website to get your application secret code, right below your API key.
- a HTTP_X_RTB_CUSTOMER_HMAC_SHA256 header, encoded using end user application secret code. To use this, you should have end user input their application secret code.

To verify that the request came from RemoveTheBackground, compute the HMAC digest according to the following algorithm and compare it to the value in the header. If they match, you can be sure that the Webhook was sent from RemoveTheBackground and the data has not been compromised.

Below is a simple example in C# using .NET framework of how one might verify a webhook request.

    public partial class CallBack : System.Web.UI.Page
    {
        private const string appCode = "my_application_secret_code";
        protected void Page_Load(object sender, EventArgs e)
        {
            string hmacHeader = Request.Headers["HTTP_X_RTB_PARTNER_HMAC_SHA256"];
            byte[] data = Request.BinaryRead(Request.ContentLength);
            if (!VerifyWebhook(appCode, data, hmacHeader))
            {
                // Write error log 
            }
        }

        private bool VerifyWebhook(string key, byte[] data, string hmacHeader)
        {
            using (HMACSHA256 hmac = new HMACSHA256(GetBytes(key)))
            {
                string calculatedHmac = Convert.ToBase64String(hmac.ComputeHash(data));
                return hmacHeader == calculatedHmac;
            }
        }

        private static byte[] GetBytes(string str)
        {
            byte[] bytes = new byte[str.Length * sizeof(char)];
            System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length);
            return bytes;
        }
    }

And here's a PHP version:

<?php
define('APP_CODE', 'my_application_secret_code');

function verify_webhook($data, $hmac_header)
{
  $calculated_hmac = base64_encode(hash_hmac('sha256', $data, APP_CODE, true));
  return ($hmac_header == $calculated_hmac);
}

$hmac_header = $_SERVER['HTTP_X_RTB_PARTNER_HMAC_SHA256'];
$data = file_get_contents('php://input');
$verified = verify_webhook($data, $hmac_header);
error_log('Webhook verified: '.var_export($verified, true)); //check error.log to see the result
?>