> ## Documentation Index
> Fetch the complete documentation index at: https://docs.b3os.org/llms.txt
> Use this file to discover all available pages before exploring further.

# POST /v1/x402-endpoints

Create (import) a new x402 endpoint after successful test

` POST /v1/x402-endpoints `

Create (import) a new x402 endpoint after successful test

## Request body (required)

Content type: ` application/json `

Endpoint details

- ` value `: type ` unknown `

  - ` oneOf alternative 1 `: type ` object `

  - ` oneOf alternative 2 `: type ` object `

    - Required fields: ` baseUrl `, ` network `, ` payTo `, ` price `, ` tokenAddress `

    - ` baseUrl `: type ` string ` — Endpoint identity

    - ` bodyParams `: type ` object `

    - ` category `: type ` string `

      - maxLength: ` 50 `

    - ` defaultBody `: type ` object `

    - ` defaultHeaders `: type ` object `

    - ` defaultQueryParams `: type ` object ` — Default values (applied if user doesn't provide at runtime)

    - ` description `: type ` string `

      - maxLength: ` 500 `

    - ` exampleBody `: type ` unknown `

    - ` exampleOutput `: type ` unknown `

    - ` exampleQueryParams `: type ` object ` — Examples (for AI/docs/UI)

    - ` headerParams `: type ` object `

    - ` method `: type ` string `

      - enum: ` ["GET","POST","PUT","PATCH","DELETE"] `

    - ` mimeType `: type ` string `

    - ` name `: type ` string ` — Metadata (optional - AI generates if empty)

      - maxLength: ` 100 `

    - ` network `: type ` string `

    - ` outputSchema `: type ` object ` — Output schema

    - ` payTo `: type ` string `

    - ` price `: type ` string ` — Payment info (from probe)

    - ` queryParams `: type ` object ` — Input configuration (CDP-aligned flat structure) Format: {"paramName": {"type": "string", "description": "...", "required": true}}

    - ` source `: type ` string ` — user_import or cdp_bazaar

    - ` tags `: type ` array `

      - ` array item `: type ` string `

    - ` tokenAddress `: type ` string `

    - ` tokenDecimals `: type ` integer `

    - ` tokenSymbol `: type ` string `

## Responses

### ` 200 ` — OK

Content type: ` application/json `

- ` value `: type ` object `

  - ` code `: type ` integer `

    - example: ` 200 `

  - ` data `: type ` object `

    - ` avgResponseMs `: type ` integer `

    - ` baseUrl `: type ` string ` — === ENDPOINT IDENTITY === BaseURL is the clean URL without query params (e.g., "https://api.example.com/search")

    - ` bodyParams `: type ` object `

    - ` category `: type ` string `

    - ` createdAt `: type ` string ` — === TIMESTAMPS ===

    - ` defaultBody `: type ` object `

    - ` defaultHeaders `: type ` object `

    - ` defaultQueryParams `: type ` object ` — Default values (applied if user doesn't provide at runtime)

    - ` description `: type ` string `

    - ` exampleBody `: type ` unknown `

    - ` exampleOutput `: type ` unknown `

    - ` exampleQueryParams `: type ` object ` — === EXAMPLES ===

    - ` failureCount `: type ` integer `

    - ` headerParams `: type ` object `

    - ` id `: type ` string `

    - ` inputSummary `: type ` string `

    - ` lastCalledAt `: type ` string `

    - ` lastError `: type ` string `

    - ` lastErrorAt `: type ` string `

    - ` maxAllowedPrice `: type ` string ` — Price protection (auto 5x of import price)

    - ` method `: type ` string ` — GET, POST, PUT, DELETE

    - ` mimeType `: type ` string `

    - ` name `: type ` string ` — === METADATA ===

    - ` network `: type ` string `

    - ` outputSchema `: type ` object ` — === OUTPUT ===

    - ` outputSummary `: type ` string `

    - ` payTo `: type ` string `

    - ` price `: type ` string ` — === PAYMENT INFO ===

    - ` queryParams `: type ` object ` — === INPUT CONFIGURATION === CDP-aligned flat structure: {"paramName": {"type": "string", "description": "...", "required": true}}

    - ` source `: type ` string `

      - enum: ` ["user_import","cdp_bazaar"] `

    - ` spentByToken `: type ` object ` — Multi-token spending tracker: {"0x833...": "50000", "0xb3b...": "1000000000000000000"}

    - ` successCount `: type ` integer ` — === STATS ===

    - ` tags `: type ` array `

      - ` array item `: type ` string `

    - ` tokenAddress `: type ` string `

    - ` tokenDecimals `: type ` integer `

    - ` tokenSymbol `: type ` string `

    - ` totalCalls `: type ` integer `

    - ` updatedAt `: type ` string `

    - ` useCases `: type ` array ` — === AI FIELDS ===

      - ` array item `: type ` string `

  - ` message `: type ` string `

    - example: ` "success" `

  - ` requestId `: type ` string `

    - example: ` "abc-123" `

### ` 400 ` — Bad Request

Content type: ` application/json `

- ` value `: type ` object `

  - ` code `: type ` integer `

  - ` details `: type ` array `

    - ` array item `: type ` unknown `

  - ` message `: type ` string `

  - ` requestId `: type ` string `

## Request examples

### cURL

```curl
curl -X POST 'https://api.example.com/v1/x402-endpoints' \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{}'
```

### JavaScript

```javascript
const response = await fetch('https://api.example.com/v1/x402-endpoints', {
  method: 'POST',
  headers: {
      "Authorization": "Bearer YOUR_API_TOKEN",
      "Content-Type": "application/json"
  },
  body: JSON.stringify({})
});

const data = await response.json();
console.log(data);
```

### Python

```python
import requests

headers = {
    'Authorization': 'Bearer YOUR_API_TOKEN'
}

response = requests.post('https://api.example.com/v1/x402-endpoints', headers=headers, json={})
print(response.json())
```

### Go

```go
package main

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

func main() {
	body := strings.NewReader(`{}`)
	req, _ := http.NewRequest("POST", "https://api.example.com/v1/x402-endpoints", body)
	req.Header.Set("Authorization", "Bearer YOUR_API_TOKEN")
	req.Header.Set("Content-Type", "application/json")

	resp, _ := http.DefaultClient.Do(req)
	defer resp.Body.Close()
	result, _ := io.ReadAll(resp.Body)
	fmt.Println(string(result))
}
```