Every API here is available over the APIs.io API and to AI agents over MCP.
openapi: 3.2.0
info:
title: Porkbun API v3 Closeouts API
version: '3.109'
description: 'The Porkbun API enables programmatic domain registration, DNS management, SSL certificate retrieval, and related operations. It is fully usable by AI agents, automation scripts, and developer tools. ## Sandbox / test mode
Build and test an integration end-to-end with **no real registry actions, no DNS changes, no certificates, and no charges** by using a **sandbox API key** — a public key prefixed `pk1_sb_` (secret `sk1_sb_`), created at https://porkbun.com/account/api. Same base URL; just swap the key. In sandbox:
- **A sandbox key sees only sandbox data.** Domains, DNS records, contacts and everything else in your live Porkbun account are invisible to it, including on a key you created on your own API Access page. Calling a live domain in the sandbox returns `INVALID_DOMAIN` for that reason, not because the name is wrong. - **Everything in the sandbox is created through the API.** The website only creates the keys. Register a test domain with `POST /domain/create/{domain}` first; that also creates its DNS zone, so there is no separate zone step. - **First steps:** `POST /domain/checkDomain/{name}` on a name nobody has registered, then `POST /domain/create/{domain}`, then `POST /dns/create/{domain}`, then `GET /dns/retrieve/{domain}`. - Every response includes `"sandbox": true` and an `X-Porkbun-Sandbox: true` header. - Registrations, renewals, transfers, DNS, contacts, nameservers, glue, and DNSSEC are simulated against an isolated datastore; your account starts with fake credit (top up/reset via `/sandbox/topup` and `/sandbox/reset`). Availability and pricing reflect the real catalog so quotes match production. - Endpoints that can''t be simulated — **hosting**, **email**, **closeouts** and **agent naming (ANS)** — return `SANDBOX_UNSUPPORTED`. Closeouts are excluded because the inventory and the purchase both live with a third party that has no test environment, so a simulated buy would claim a real domain. - **Webhooks are delivered in the sandbox.** Register an endpoint with `POST /webhook/create`, then either perform an operation (the matching signed event is delivered just like production) or fire any event on demand with `POST /sandbox/triggerWebhook` to test your handler and signature verification. ## Mock server (no credentials)
Learn any endpoint''s exact response shape with **zero setup** — no key, no account. Every real path is mirrored under `/mock`:
- `GET /mock` lists every mockable endpoint. - `GET|POST /mock/` returns a schema-accurate example response for that operation (e.g. `/mock/domain/listAll`). Append `?status=error` for the error shape. Mock responses touch no datastore, are identical in shape to the live API, and are signalled by an `X-Porkbun-Mock: true` header. Use it to build client code before you have credentials; switch to a sandbox key when you want real behavior with fake money. ## Quickstart
**1. Get your API keys** — visit https://porkbun.com/account/api
**2. Test connectivity**
```bash
curl https://api.porkbun.com/api/json/v3/ip
```
Returns your public IP. No credentials required. **3. Check domain availability** (also verifies your credentials)
```bash
curl -X POST https://api.porkbun.com/api/json/v3/domain/checkDomain/example.com \
-H "Content-Type: application/json" \
-d ''{"apikey":"your_api_key","secretapikey":"your_secret_key"}''
```
Returns `avail: "yes"/"no"` and `price` in USD. Returns an error if credentials are invalid. **4. Register the domain** — convert `price` to pennies (e.g. $9.73 → 973) for `cost`
```bash
curl -X POST https://api.porkbun.com/api/json/v3/domain/create/example.com \
-H "Content-Type: application/json" \
-d ''{"apikey":"your_api_key","secretapikey":"your_secret_key","cost":973,"agreeToTerms":"yes"}''
```
**5.'
contact:
name: Porkbun Support
url: https://porkbun.com/support
x-logo:
url: https://porkbun.com/img/logo.png
servers:
- url: https://api.porkbun.com/api/json/v3
description: Production
- url: https://api-ipv4.porkbun.com/api/json/v3
description: Production (IPv4 only — use this if your client is on an IPv6 network and needs to reach the API over IPv4)
security:
- ApiKeyHeader: []
SecretApiKeyHeader: []
tags:
- name: Closeouts
description: 'Expired domains that did not sell at auction, offered at a fixed price with no bidding — first buyer at the current price takes the name.
The price descends on a schedule, so a listing is often gone within minutes; treat a search result as perishable and re-check the price before buying.
Search returns `age` and `registrationDate` on every row and both are sortable, which is the part the website cannot do — it paginates by price tier and does not show registration date at all.'
paths:
/closeout/search:
get:
tags:
- Closeouts
summary: Search expired-domain closeouts
operationId: closeoutSearch
description: 'Search the closeout inventory. Closeouts are expired domains that did not sell at auction and are now offered at a fixed, descending price — there is no bidding, the first buyer at the current price takes the name.
Every filter is optional; with none you get the first page of the whole list plus `totalAvailable`. Page with `start`/`limit` until `start >= totalAvailable`.
**`age` and `registrationDate` are on every row and both are sortable.** On the website the inventory is paginated by price tier and registration date is not shown, so finding aged names means walking several tier pages and then doing a WHOIS lookup per candidate. `sortName=registrationDate&sortDirection=asc` returns the oldest registrations first in one call.
`price` is the closeout price alone. The binding total adds the renewal or transfer year you are also buying, and comes from `/closeout/get/{domain}` — it cannot be derived from search results, because a domain already at Porkbun is renewed while anything else is transferred in, and those are priced differently.'
parameters:
- name: query
in: query
required: false
schema:
type: string
description: Keyword match on the domain name.
example: invest
- name: tld
in: query
required: false
schema:
type: string
description: Single TLD, with or without the leading dot. Omit to search all.
example: org
- name: nameLength
in: query
required: false
schema:
type: integer
description: Exact SLD character count.
example: 4
- name: ageMin
in: query
required: false
schema:
type: integer
description: Minimum domain age in years. Pair with sortName=registrationDate to find aged names.
example: 10
- name: ageMax
in: query
required: false
schema:
type: integer
description: Maximum domain age in years.
example: 30
- name: priceMin
in: query
required: false
schema:
type: integer
description: Minimum closeout price, integer US cents. Converted to whole dollars for the provider, rounding outward so the range never excludes an item inside it.
example: 500
- name: priceMax
in: query
required: false
schema:
type: integer
description: Maximum closeout price, integer US cents.
example: 3000
- name: sortName
in: query
required: false
schema:
type: string
description: 'One of: domain, endTime, price, revenue, visitors, inboundLinks, registrationDate. Ascending on registrationDate means oldest registration first, which is how you find aged names. Ascending on revenue, visitors or inboundLinks puts the domains with no recorded figure first (they return null) — use desc on those to see the highest values; the response carries a `warnings` entry reminding you.'
example: registrationDate
- name: sortDirection
in: query
required: false
schema:
type: string
description: '`asc` or `desc`.'
example: asc
- name: start
in: query
required: false
schema:
type: integer
description: Offset for paging. Default 0.
example: 0
- name: limit
in: query
required: false
schema:
type: integer
description: Rows per page, 1-500. Default 100.
example: 100
responses:
'200':
description: Matching closeouts.
content:
application/json:
schema:
type: object
properties:
status:
type: string
count:
type: integer
totalAvailable:
type: integer
description: Size of the filtered set, for paging.
start:
type: integer
limit:
type: integer
closeouts:
type: array
items:
$ref: '#/components/schemas/CloseoutItem'
headers:
X-RateLimit-Limit:
$ref: '#/components/headers/XRateLimitLimit'
X-RateLimit-Remaining:
$ref: '#/components/headers/XRateLimitRemaining'
X-RateLimit-Reset:
$ref: '#/components/headers/XRateLimitReset'
X-RateLimit-Window:
$ref: '#/components/headers/XRateLimitWindow'
X-RateLimit-Mode:
$ref: '#/components/headers/XRateLimitMode'
'400':
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: Invalid filter (`INVALID_INPUT`, `INVALID_TLD`)
'502':
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: Inventory provider unreachable (`CLOSEOUT_SOURCE_UNAVAILABLE`)
'429':
$ref: '#/components/responses/RateLimited'
x-porkbun-agent:
safe: true
cost: false
destructive: false
reversible: true
requiresConfirmation: false
x-porkbun-scope: read
/closeout/get/{domain}:
get:
tags:
- Closeouts
summary: One closeout, with the binding total
operationId: closeoutGet
description: 'A single closeout plus `totalPrice` — the closeout price plus the registration year that comes with it. That total is what `/closeout/buy` will charge and what it expects back as `cost`.
`localDomain` tells you which side of the pricing you are on: true means the name is already at Porkbun and is renewed, false means it is transferred in. `available` is false once somebody has claimed it.'
parameters:
- name: domain
in: path
required: true
schema:
type: string
example: example.com
responses:
'200':
description: The closeout.
content:
application/json:
schema:
type: object
properties:
status:
type: string
available:
type: boolean
closeout:
$ref: '#/components/schemas/CloseoutItem'
headers:
X-RateLimit-Limit:
$ref: '#/components/headers/XRateLimitLimit'
X-RateLimit-Remaining:
$ref: '#/components/headers/XRateLimitRemaining'
X-RateLimit-Reset:
$ref: '#/components/headers/XRateLimitReset'
X-RateLimit-Window:
$ref: '#/components/headers/XRateLimitWindow'
X-RateLimit-Mode:
$ref: '#/components/headers/XRateLimitMode'
'404':
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: Not currently offered as a closeout (`CLOSEOUT_NOT_FOUND`)
'502':
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: '`CLOSEOUT_SOURCE_UNAVAILABLE` or `PRICING_UNAVAILABLE`'
'429':
$ref: '#/components/responses/RateLimited'
x-porkbun-agent:
safe: true
cost: false
destructive: false
reversible: true
requiresConfirmation: false
x-porkbun-scope: read
/closeout/buy/{domain}:
post:
tags:
- Closeouts
summary: Buy a closeout outright
operationId: closeoutBuy
description: '**Spends account credit, or pays directly in USDC with `"payWith": "usdc"` (HTTP 402, then repeat with `PAYMENT-SIGNATURE`; kept as account credit if the claim fails), or by card with `"payWith": "card"` (a hold, captured only if the claim succeeds).** Counts toward the monthly API spend limit. Buys a closeout at its current price and claims the name with the provider in one call. Send `cost` as the exact `totalPrice` from `/closeout/get/{domain}`; any other value is refused with `COST_MISMATCH` so a caller can never be charged a price it did not name. `dryRun: true` with `cost: 0` returns a quote and charges nothing. Honours `Idempotency-Key`.
**The domain does not arrive immediately.** Claiming reserves it; the provider then has to release it, which usually takes a few days. Poll `/domain/listAll` or subscribe to the `domain.registered` webhook rather than expecting it in your account when this returns.
Every post-charge failure refunds automatically and says so via `refunded: true` — including losing the race to another buyer (`CLOSEOUT_UNAVAILABLE`) and the price moving between quote and claim (`COST_MISMATCH`). Closeouts are first-come at a fixed price, so a lost race is not worth retrying on the same name.
Not available with a sandbox key (`SANDBOX_UNSUPPORTED`): the inventory provider has no test environment, so a purchase cannot be rehearsed without claiming a real name. Use `dryRun` against a live key instead — it validates and prices without charging.
Eligibility is the same as registering a domain, plus verified email and phone. There is no account-age or prior-order requirement — a first-time customer can buy a closeout, which matters because listings are first-come and often gone within minutes. An account that support has blocked from auctions and closeouts (past-due invoices, or an auction terms violation) returns `CLOSEOUT_NOT_ELIGIBLE`, which is not retryable.'
parameters:
- name: domain
in: path
required: true
schema:
type: string
example: example.com
- $ref: '#/components/parameters/IdempotencyKey'
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- cost
properties:
cost:
type: integer
description: Exact totalPrice in integer US cents, from /closeout/get/{domain}. Use 0 only with dryRun to request a quote.
example: 1684
payWith:
type: string
enum:
- usdc
- card
description: 'Optional. `"usdc"` pays for this purchase directly in USDC on Base over x402 instead of from account credit. The first call answers HTTP 402 (`PAYMENT_REQUIRED`) with Coinbase''s terms in the `PAYMENT-REQUIRED` header and charges nothing; an x402 client pays and repeats the same request with a `PAYMENT-SIGNATURE` header, and the purchase completes in that call. If it then fails, the payment stays on the account as account credit; it is not sent back to the wallet. If your wallet pays URLs itself instead, pay the 402''s `x402Url` (or have a person pay `payUrl`) and repeat the request with `usdcCheckoutId`. See the guide: https://porkbun.com/llms/guides/pay-with-usdc-x402. `"card"` pays by card through a Stripe Link agent wallet over MPP instead, with a real hold: the 402 carries a single-use `payUrl` and a `cardPaymentId`; pay the link (it authorizes, not charges), then repeat with `cardPaymentId`; the hold is captured if the purchase succeeds and released if it fails. Guide: https://porkbun.com/llms/guides/pay-with-card-mpp'
usdcCheckoutId:
type: string
description: 'With `payWith: "usdc"`: the `checkoutId` from an earlier `PAYMENT_REQUIRED`, once its `x402Url` or `payUrl` has been paid. Send it with otherwise the same request; the purchase completes if the checkout is paid and was opened for this purchase.'
cardPaymentId:
type: string
description: 'With `payWith: "card"`: the `cardPaymentId` from an earlier `PAYMENT_REQUIRED`, once its `payUrl` has been paid (the card is then held). Send it with otherwise the same request; the hold is captured if the purchase succeeds and released if not.'
dryRun:
type: boolean
description: Validate and price without charging or claiming.
example: true
responses:
'200':
description: Claimed, or a dry-run quote.
content:
application/json:
schema:
type: object
properties:
status:
type: string
domain:
type: string
orderId:
type: integer
closeoutId:
type: integer
closeoutPrice:
type: integer
renewalPrice:
type: integer
totalPrice:
type: integer
message:
type: string
headers:
X-RateLimit-Limit:
$ref: '#/components/headers/XRateLimitLimit'
X-RateLimit-Remaining:
$ref: '#/components/headers/XRateLimitRemaining'
X-RateLimit-Reset:
$ref: '#/components/headers/XRateLimitReset'
X-RateLimit-Window:
$ref: '#/components/headers/XRateLimitWindow'
X-RateLimit-Mode:
$ref: '#/components/headers/XRateLimitMode'
'400':
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: '`COST_MISMATCH`, `INVALID_INPUT`, `UNSUPPORTED_TLD`, `INSUFFICIENT_FUNDS`'
'403':
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: '`CLOSEOUT_NOT_ELIGIBLE`, `VERIFICATION_REQUIRED`, `ORDERS_BLOCKED`'
'404':
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: '`CLOSEOUT_NOT_FOUND`'
'409':
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: Already claimed by another buyer (`CLOSEOUT_UNAVAILABLE`)
'429':
$ref: '#/components/responses/RateLimited'
x-porkbun-agent:
safe: false
cost: true
destructive: false
reversible: false
requiresConfirmation: true
x-porkbun-scope: purchase
components:
responses:
RateLimited:
description: Rate limit exceeded (code RATE_LIMIT_EXCEEDED). Wait Retry-After seconds, then retry the same request.
headers:
Retry-After:
$ref: '#/components/headers/RetryAfter'
X-RateLimit-Limit:
$ref: '#/components/headers/XRateLimitLimit'
X-RateLimit-Remaining:
$ref: '#/components/headers/XRateLimitRemaining'
X-RateLimit-Reset:
$ref: '#/components/headers/XRateLimitReset'
X-RateLimit-Window:
$ref: '#/components/headers/XRateLimitWindow'
X-RateLimit-Mode:
$ref: '#/components/headers/XRateLimitMode'
content:
application/json:
schema:
$ref: '#/components/schemas/RateLimitExceeded'
headers:
RetryAfter:
description: 'On 429: whole seconds to wait before retrying.'
schema:
type: integer
XRateLimitLimit:
description: Requests allowed per window for this API key (the general per-key limiter).
schema:
type: integer
XRateLimitRemaining:
description: Requests left in the current window for this API key.
schema:
type: integer
XRateLimitReset:
description: Seconds until the current window resets.
schema:
type: integer
XRateLimitWindow:
description: Window length in seconds.
schema:
type: integer
XRateLimitMode:
description: '`observe` while the general per-key limiter only measures and refuses nothing. Endpoint-specific limits (availability checks, registrations, renewals and others) are enforced regardless, with 429 and Retry-After.'
schema:
type: string
enum:
- observe
schemas:
CloseoutItem:
type: object
properties:
closeoutId:
type: integer
description: Provider id for this listing.
domain:
type: string
tld:
type: string
price:
type: integer
description: Current closeout price, integer US cents. Descends on a schedule.
providerRenewalPrice:
type:
- integer
- 'null'
description: The provider's own renewal figure. Indicative only — the amount actually charged is `renewalPrice` from /closeout/get/{domain}, which uses Porkbun pricing.
renewalPrice:
type:
- integer
- 'null'
description: Porkbun's renewal or transfer price for the year included. Only returned by /closeout/get/{domain}.
totalPrice:
type:
- integer
- 'null'
description: price + renewalPrice. What /closeout/buy charges. Only returned by /closeout/get/{domain}.
localDomain:
type:
- boolean
- 'null'
description: True when the name is already at Porkbun (renewed rather than transferred in). Only returned by /closeout/get/{domain}.
age:
type:
- integer
- 'null'
description: Domain age in years.
registrationDate:
type:
- string
- 'null'
description: Original registration date, ISO 8601 UTC.
endTime:
type:
- string
- 'null'
description: When the listing ends, ISO 8601 UTC.
nameLength:
type:
- integer
- 'null'
isIdn:
type: boolean
estibotAppraisal:
type:
- integer
- 'null'
description: Third-party appraisal in US cents. Provider-supplied; treat as a weak signal.
monthlyVisitors:
type:
- integer
- 'null'
inboundLinks:
type:
- integer
- 'null'
expiredRevenue:
type:
- integer
- 'null'
otherTldCount:
type:
- integer
- 'null'
description: How many other TLDs the same SLD is registered in.
RateLimitExceeded:
type: object
required:
- status
- message
properties:
status:
type: string
enum:
- ERROR
example: ERROR
message:
type: string
example: Rate limit exceeded. Please try again later.
code:
type: string
example: RATE_LIMIT_EXCEEDED
ttlRemaining:
type: integer
description: Seconds until the rate limit window resets. Present on some endpoints.
ErrorResponse:
type: object
required:
- status
- message
properties:
status:
type: string
enum:
- ERROR
example: ERROR
message:
type: string
description: Human-readable description of the error
example: Invalid domain.
code:
type: string
description: Machine-readable error code. Use for programmatic handling; use `message` for display. See the Error codes section in the API description for a full list.
example: INVALID_DOMAIN
account:
type: string
description: 'On DOMAIN_NOT_FOUND, DOMAIN_NOT_REGISTERED, API_ACCESS_DISABLED and the /dns/* INVALID_DOMAIN: the username of the account the key belongs to'
next_action:
type: object
description: 'Present on many errors: a machine-readable remediation hint so an agent can self-correct without parsing the message. Absent when no specific action applies.'
properties:
type:
type: string
description: Stable action category an agent can branch on.
enum:
- fix_request
- authenticate
- enable_setting
- verify_account
- add_funds
- top_up
- retry
- wait_and_retry
- pay
- use_website
- choose_alternative
- contact_support
- none
example: fix_request
hint:
type: string
description: Human-readable instruction.
example: Re-fetch the price via /domain/checkDomain and resend the matching cost.
url:
type: string
description: Where to take the action, when applicable.
example: https://porkbun.com/account/api
parameters:
IdempotencyKey:
name: Idempotency-Key
in: header
required: false
schema:
type: string
maxLength: 255
description: Optional, recommended on every purchase and write. Send a unique value (a UUID) per intended operation. Repeating the request with the same key and an identical body within 24 hours returns the original response instead of doing it again, so a retry after a timeout cannot double-charge or double-apply. The same key with a different body returns 409 IDEMPOTENCY_KEY_MISMATCH; while the first request is still running, 409 IDEMPOTENCY_KEY_IN_USE.
example: 3f0c9a52-6d1e-4c8e-9b7a-2f5d1e0c4a11
securitySchemes:
ApiKeyHeader:
type: apiKey
in: header
name: X-API-Key
description: Your API key. Use together with X-Secret-API-Key.
SecretApiKeyHeader:
type: apiKey
in: header
name: X-Secret-API-Key
description: Your secret API key. Use together with X-API-Key.