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

Register a user

POSThttps://api.testingapis.com/api/validation/register

Register a user; invalid fields return 422 problem+json.

Rules: <list type="bullet"><item><description>username: 3-20 letters, digits or underscores; admin, root, apibee and test_user are taken</description></item><item><description>email: must be a valid address</description></item><item><description>password: 8+ characters with an uppercase letter, a lowercase letter, a digit and a special character</description></item><item><description>confirmPassword: if present, must match password</description></item><item><description>age: integer, 18-120</description></item><item><description>country: one of US, GB, IN, DE, FR, JP, CA, AU, BR</description></item><item><description>phone: optional, E.164 format</description></item><item><description>acceptTerms: must be true</description></item></list> Errors come back as RFC 7807 application/problem+json, with an errors map of field to messages. Nothing is stored, so the same payload always gets the same answer.

Request body

Optional. application/json, text/json, application/*+json, application/xml, text/xml, application/*+xml. JSON object with username, email, password, optional confirmPassword, age, country, optional phone and acceptTerms.

Example body
{
  "username": "ava_t",
  "email": "ava@example.com",
  "password": "Str0ng!Pass",
  "confirmPassword": "Str0ng!Pass",
  "age": 29,
  "country": "us",
  "phone": "+15550101",
  "acceptTerms": true
}

Responses

200
OK
201
User registered (the password is never echoed back).
400
Body is not a JSON object.
422
One or more fields failed validation.

Example

Request
curl -X POST "https://api.testingapis.com/api/validation/register" \
  -H "Content-Type: application/json" \
  -d '{"username": "ava_t", "email": "ava@example.com", "password": "Str0ng!Pass", "confirmPassword": "Str0ng!Pass", "age": 29, "country": "us", "phone": "+15550101", "acceptTerms": true}'
Run in Studio
Response201 Created
{
  "message": "User registered successfully",
  "data": {
    "id": 1001,
    "username": "ava_t",
    "email": "ava@example.com",
    "age": 29,
    "country": "US",
    "createdAt": "2026-09-30T18:26:45Z"
  }
}

Code examples

JavaScript (fetch)
const response = await fetch("https://api.testingapis.com/api/validation/register", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: "{\"username\": \"ava_t\", \"email\": \"ava@example.com\", \"password\": \"Str0ng!Pass\", \"confirmPassword\": \"Str0ng!Pass\", \"age\": 29, \"country\": \"us\", \"phone\": \"+15550101\", \"acceptTerms\": true}",
});
console.log(response.status, await response.text());
Python (requests)
import requests

response = requests.request(
    "POST",
    "https://api.testingapis.com/api/validation/register",
    headers={
        "Content-Type": "application/json",
    },
    data="{\"username\": \"ava_t\", \"email\": \"ava@example.com\", \"password\": \"Str0ng!Pass\", \"confirmPassword\": \"Str0ng!Pass\", \"age\": 29, \"country\": \"us\", \"phone\": \"+15550101\", \"acceptTerms\": true}".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/validation/register"))
            .header("Content-Type", "application/json")
            .method("POST", HttpRequest.BodyPublishers.ofString("{\"username\": \"ava_t\", \"email\": \"ava@example.com\", \"password\": \"Str0ng!Pass\", \"confirmPassword\": \"Str0ng!Pass\", \"age\": 29, \"country\": \"us\", \"phone\": \"+15550101\", \"acceptTerms\": true}"))
            .build();

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