Responses and errors

Vudy API responses use a JSON envelope. Check the HTTP status and success, and use error.code for programmatic error handling.

Success#

{
	"success": true,
	"data": {}
}

HTTP status is typically 200 or 201 depending on the endpoint.

Error#

{
	"success": false,
	"error": {
		"code": "SERVER_VALIDATION_API_AUTH_02",
		"message": "Human-readable explanation",
		"details": {}
	}
}
FieldMeaning
error.codeMachine-readable identifier, such as SERVER_VALIDATION_API_AUTH_02
error.messageHuman-readable summary; wording can change
error.detailsOptional structured context; shape depends on the error

Current error codes use uppercase underscore-separated identifiers ending in a two-digit number. Treat the complete value as opaque: do not construct codes or infer behavior from individual segments. For example, API-key limits return SERVER_VALIDATION_API_AUTH_12 (hourly) or SERVER_VALIDATION_API_AUTH_19 (burst).

Common HTTP statuses#

StatusWhen
200 / 201Success
400Invalid body, query, or request-specific validation
401Missing/invalid required session or unresolved conditional context
403API-key authentication, permission, or route-level access failure
404Resource not found
409Conflict
429API-key hourly or burst limit exceeded
500Unexpected server failure
503A required platform access gate is closed

Useful response headers#

HeaderMeaning
x-trace-idRequest correlation ID to include in support requests
RateLimit-LimitLimit for the window represented by the response
RateLimit-RemainingRemaining requests in that window
RateLimit-ResetSeconds until that window resets
RateLimit-PolicyHourly and per-second policies, for example 1000;w=3600, 100;w=1
Retry-AfterWhole seconds to wait; present when a rate limit blocks a request

Handling errors in JavaScript#

async function callVudy(path, options = {}) {
	const res = await fetch(`https://api-stg.vudy.app${path}`, {
		...options,
		headers: {
			"x-api-key": process.env.VUDY_API_KEY,
			"Content-Type": "application/json",
			...(options.headers || {}),
		},
	});

	const body = await res.json();
	if (!res.ok || !body.success) {
		const err = new Error(body.error?.message || "Vudy API error");
		err.code = body.error?.code;
		err.details = body.error?.details;
		err.status = res.status;
		err.traceId = res.headers.get("x-trace-id");
		throw err;
	}
	return body.data;
}

Do not retry a failed mutation unless its endpoint contract documents safe retry or idempotency behavior. For 429, wait for Retry-After; for 503, check platform maintenance status before retrying.

See Rate limits and maintenance and Troubleshooting.