New in 2.4: Test runs you can trust See what's new →

Capture any request sent to a bin

GETPOSTPUTPATCHDELETEHEADOPTIONShttps://api.testingapis.com/api/webhooks/{binId}

Accepts GET, POST, PUT, PATCH, DELETE, HEAD and OPTIONS. Text bodies are stored as UTF-8; other bodies are stored as base64. Bodies over 256KB are truncated (bodyTruncated: true). No outbound calls are ever made.

Parameters 2

NameTypeDescription
binIdrequiredpath · stringBin id from POST /api/webhooks/bins.
statusquery · integer (int32)Status code to reply with (200-599, default 200). 204 and 304 reply without a body. Default: 200.

Request body

Optional. application/json. Any payload; it is captured in the bin.

Example body
{"event": "order.created", "id": 42}

Responses

200
Request captured (or the status chosen with status).
400
status is out of range.
404
No bin with that id.

Example

Request
curl -X POST "https://api.testingapis.com/api/webhooks/cbaa7309f444" \
  -H "Content-Type: application/json" \
  -d '{"event": "order.created", "id": 42}'
Run in Studio
Response200 OK
{
  "received": true,
  "binId": "cbaa7309f444",
  "requestId": "req_bff48fcc8d8a",
  "message": "Request captured"
}

Code examples

JavaScript (fetch)
const response = await fetch("https://api.testingapis.com/api/webhooks/cbaa7309f444", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: "{\"event\": \"order.created\", \"id\": 42}",
});
console.log(response.status, await response.text());
Python (requests)
import requests

response = requests.request(
    "POST",
    "https://api.testingapis.com/api/webhooks/cbaa7309f444",
    headers={
        "Content-Type": "application/json",
    },
    data="{\"event\": \"order.created\", \"id\": 42}".encode("utf-8"),
    allow_redirects=False,
)
print(response.status_code, response.text)
Java (HttpClient)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        HttpClient client = HttpClient.newBuilder()
            .followRedirects(HttpClient.Redirect.NEVER)
            .build();

        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.testingapis.com/api/webhooks/cbaa7309f444"))
            .header("Content-Type", "application/json")
            .method("POST", HttpRequest.BodyPublishers.ofString("{\"event\": \"order.created\", \"id\": 42}"))
            .build();

        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.statusCode() + " " + response.body());
    }
}