Output Schema
The outputSchema in your 402 response tells x402.jobs what inputs your resource accepts and what outputs it produces. This enables automatic form generation and field mapping in workflows.
Schema Structure
{
"outputSchema": {
"input": {
"type": "http",
"method": "POST",
"bodyType": "json",
"bodyFields": { ... },
"queryParams": { ... }
},
"output": { ... }
}
}
Input Schema
For POST Requests (bodyFields)
{
"input": {
"type": "http",
"method": "POST",
"bodyType": "json",
"bodyFields": {
"prompt": {
"type": "string",
"required": true,
"description": "The prompt for image generation"
},
"style": {
"type": "string",
"required": false,
"description": "Art style",
"enum": ["realistic", "anime", "cartoon"],
"default": "realistic"
},
"width": {
"type": "integer",
"required": false,
"description": "Image width in pixels",
"default": 1024
}
}
}
}
For GET Requests (queryParams)
{
"input": {
"type": "http",
"method": "GET",
"queryParams": {
"symbol": {
"type": "string",
"required": true,
"description": "Token symbol (e.g., SOL, BTC)"
},
"timeframe": {
"type": "string",
"required": false,
"description": "Time period",
"enum": ["1h", "24h", "7d", "30d"],
"default": "24h"
}
}
}
}
Field Properties
| Property | Type | Description |
|---|---|---|
type | string | "string", "integer", "number", "boolean", "array", "object" |
required | boolean | Whether the field is required |
description | string | Human-readable description (shown in UI) |
default | any | Default value if not provided |
enum | array | List of allowed values (creates a dropdown) |
Output Schema
Describe what your resource returns:
{
"output": {
"imageUrl": {
"type": "string",
"description": "URL to the generated image"
},
"prompt": {
"type": "string",
"description": "The prompt that was used"
},
"metadata": {
"type": "object",
"description": "Additional generation metadata",
"properties": {
"seed": { "type": "integer" },
"model": { "type": "string" }
}
}
}
}
UI Generation
x402.jobs uses your schema to generate forms:
string→ Text inputstringwithenum→ Dropdown selectinteger/number→ Number inputboolean→ Toggle switchrequired: true→ Field marked with asterisk
Workflow Field Mapping
When users connect nodes, they can map fields:
[Trigger: prompt] → [Your Resource: prompt]
[Your Resource: imageUrl] → [Output: display]
The output schema enables autocomplete for field names.
Complete Example
{
"x402Version": 1,
"accepts": [{
"scheme": "exact",
"network": "solana",
"maxAmountRequired": "100000",
"resource": "https://api.example.com/generate-image",
"payTo": "YourWallet...",
"asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"description": "Generate AI images from text prompts",
"mimeType": "application/json",
"maxTimeoutSeconds": 60,
"outputSchema": {
"input": {
"type": "http",
"method": "POST",
"bodyType": "json",
"bodyFields": {
"prompt": {
"type": "string",
"required": true,
"description": "Describe the image you want"
},
"negativePrompt": {
"type": "string",
"required": false,
"description": "What to avoid in the image"
},
"aspectRatio": {
"type": "string",
"required": false,
"enum": ["1:1", "16:9", "9:16"],
"default": "1:1",
"description": "Image aspect ratio"
}
}
},
"output": {
"imageUrl": {
"type": "string",
"description": "URL to generated image"
},
"revised_prompt": {
"type": "string",
"description": "The prompt after AI enhancement"
}
}
},
"extra": {
"serviceName": "ImageGen Pro",
"avatarUrl": "https://example.com/logo.png"
}
}]
}
Tips
- Be descriptive - Good descriptions help users understand fields
- Use enums - When there are fixed options, list them
- Set defaults - Reduce friction for optional fields
- Document outputs - Help users map fields in workflows