Admin API

(Formally known as “Back Office API”)

2Checkout’s Admin API provides a way to automate both account and order management processes. Using the Admin API along with the Instant Notification Service alleviates the necessity of logging into the standard GUI account interface on a day-to-day basis.

The Admin API system works by first having the user create an API username in their 2Checkout account which has the appropriate permissions to access the Admin API. This API username can be used to authenticate the supported methods described below to call our Admin API by HTTP POST or GET to update or return sale information. To create a username, please login to your account, click on the Account tab and User Management sub-tab. From here, please click the Create Username link and create a new username with API Access and API Updating selected for the Access type. Our API can then be accessed with this new username and password you created.

The Admin API will return XML by default unless the Accept: header is passed in the call to define the content type. The Admin API is capable of returning data in the following formats:

  • XML (application/xml) - default
  • JSON (application/json)
  • HTML XOXO microformat (text/html)

Simple bindings for each method are provided through our community supported libraries.

You can also call each method without using our libraries. Below is an example PHP script that makes a detail_sale call.

<?php

    $ch = curl_init("https://www.2checkout.com/api/sales/detail_sale?sale_id=1234567890");
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/json"));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_USERAGENT, "2Checkout PHP/0.1.0");
    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($ch, CURLOPT_USERPWD, "apiusername:apipassowrd");
    $json_resp = curl_exec($ch);
    curl_close($ch);

    //decode to an associative array
    $array_resp = json_decode($json_resp, true);

    print_r($array_resp);

?>

Errors

If a request cannot be completed successfully, the response from the Admin API will contain information that can be used to determine what went wrong. There are several ways to determine that the request was unsuccessful. Either the HTTP Status header will contain a status code of 400 or higher (typically 400, 404, or 500). Or There will be one or more errors elements in the response. Each of these elements will contain an error code, message, and (if applicable) other informative values to assist in debugging the problem such as the offending parameter name.

Example response:

    {
      "code" : "PARAMETER_MISSING",
      "message" : "Required parameter missing: vendor_id",
      "parameter" : "vendor_id"
    }