> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developer.yoco.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developer.yoco.com/_mcp/server.

The following document gives an overview of how to use the Representational State Transfer (REST)
API. It includes high-level information on the live and sandbox environments, authentication, making
a request and handling responses.

For further information on a specific subject, consult the relevant section of the documentation.

## Environments

Both a live and a sandbox testing environment are available.

The **live** environment is accessible at `https://api.yoco.com`. You must use a valid live
[authentication token](/docs/api/authentication) when making requests to this API URL.

For testing, you can use the **sandbox** environment accessible at `https://api.yocosandbox.com`.
Similar to the live environment, you must use a valid sandbox
[authentication token](/docs/api/authentication) when making requests.

**Note that a live authentication token doesn't work against sandbox.**

## Authentication

All requests to the API must be accompanied by a valid authentication token issued via the
[OAuth 2.0](/docs/api/authentication/oauth) flow.

It must be specified using the `Authorization` header.

*Example:*

### Request

GET [https://api.yoco.com/v1/orders/](https://api.yoco.com/v1/orders/)

**`Retrieved`**

```curl Retrieved
curl https://api.yoco.com/v1/orders/ \
     -H "Authorization: Bearer <token>"
```

**`Retrieved`**

```python Retrieved
import requests

url = "https://api.yoco.com/v1/orders/"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.json())
```

**`Retrieved`**

```javascript Retrieved
const url = 'https://api.yoco.com/v1/orders/';
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**`Retrieved`**

```go Retrieved
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.yoco.com/v1/orders/"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

**`Retrieved`**

```ruby Retrieved
require 'uri'
require 'net/http'

url = URI("https://api.yoco.com/v1/orders/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

**`Retrieved`**

```java Retrieved
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.yoco.com/v1/orders/")
  .header("Authorization", "Bearer <token>")
  .asString();
```

**`Retrieved`**

```php Retrieved
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.yoco.com/v1/orders/', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

**`Retrieved`**

```csharp Retrieved
using RestSharp;

var client = new RestClient("https://api.yoco.com/v1/orders/");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

**`Retrieved`**

```swift Retrieved
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.yoco.com/v1/orders/")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

## Resources

A resource is a thing you act upon, such as an `order`, `payment` or `refund`.

You can view a full list of available resources in the API reference.

## HTTP methods

When interacting with the API, you use an HTTP method to act upon a resource.

The common actions are:

* `GET`: Retrieve information about a resource.
* `POST`: Create a new resource.
* `PUT`: Update a resource.
* `DELETE`: Remove a resource.
* `PATCH`: Perform a partial update to a resource.

The following fictitious examples illustrate practical use:

* Retrieve an order: `GET /v1/orders/1851231235`
* Retrieve a list of open orders: `GET /v1/orders/?status=OPEN`
* Update an order: `PUT /v1/orders/1851231235`
* Delete or cancel an order: `DELETE /v1/orders/1851231235`
* Perform a partial update to an order: `PATCH /v1/orders/1851231235`

## Making a request

When making a `GET` request to retrieve a single resource or list of resources, you often use query
string parameters to add additional context to your request.

The following example makes a `GET` request to retrieve a paginated list of open orders.

```shell
curl https://api.yoco.com/v1/orders/?status=OPEN \
  -H 'Authorization: Bearer <access token>'
```

Unless noted otherwise, most `PUT`, `PATCH`, and `POST` requests require you to send the resource
data as a JSON payload in the request body.

The following example makes a `POST` request to create a payment link.

### Request

POST [https://api.yoco.com/v1/payment_links/](https://api.yoco.com/v1/payment_links/)

```curl
curl -X POST https://api.yoco.com/v1/payment_links/ \
     -H "Authorization: Bearer <token>" \
     -H "Content-Type: application/json" \
     -d '{
  "amount": {
    "amount": 1500,
    "currency": "ZAR"
  },
  "customer_reference": "Peter Parker",
  "customer_description": "This description is visible to the customer on the payment page."
}'
```

```python
import requests

url = "https://api.yoco.com/v1/payment_links/"

payload = {
    "amount": {
        "amount": 1500,
        "currency": "ZAR"
    },
    "customer_reference": "Peter Parker",
    "customer_description": "This description is visible to the customer on the payment page."
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.yoco.com/v1/payment_links/';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"amount":{"amount":1500,"currency":"ZAR"},"customer_reference":"Peter Parker","customer_description":"This description is visible to the customer on the payment page."}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.yoco.com/v1/payment_links/"

	payload := strings.NewReader("{\n  \"amount\": {\n    \"amount\": 1500,\n    \"currency\": \"ZAR\"\n  },\n  \"customer_reference\": \"Peter Parker\",\n  \"customer_description\": \"This description is visible to the customer on the payment page.\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.yoco.com/v1/payment_links/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"amount\": {\n    \"amount\": 1500,\n    \"currency\": \"ZAR\"\n  },\n  \"customer_reference\": \"Peter Parker\",\n  \"customer_description\": \"This description is visible to the customer on the payment page.\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.yoco.com/v1/payment_links/")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"amount\": {\n    \"amount\": 1500,\n    \"currency\": \"ZAR\"\n  },\n  \"customer_reference\": \"Peter Parker\",\n  \"customer_description\": \"This description is visible to the customer on the payment page.\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.yoco.com/v1/payment_links/', [
  'body' => '{
  "amount": {
    "amount": 1500,
    "currency": "ZAR"
  },
  "customer_reference": "Peter Parker",
  "customer_description": "This description is visible to the customer on the payment page."
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.yoco.com/v1/payment_links/");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"amount\": {\n    \"amount\": 1500,\n    \"currency\": \"ZAR\"\n  },\n  \"customer_reference\": \"Peter Parker\",\n  \"customer_description\": \"This description is visible to the customer on the payment page.\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "amount": [
    "amount": 1500,
    "currency": "ZAR"
  ],
  "customer_reference": "Peter Parker",
  "customer_description": "This description is visible to the customer on the payment page."
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.yoco.com/v1/payment_links/")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

## Handling a response

All API calls return a JSON response, unless stated otherwise.

A **successful** response is indicated by a 2XX HTTP status code.

The most common HTTP 2XX status codes returned by the API are:

* [200 OK](https://http.dev/200)
* [201 Created](https://http.dev/201)
* [204 No Content](https://http.dev/204)

An **error** response is indicated by a 4XX or 5XX HTTP status code.

See [error handling](/docs/api/error-handling) for more details.