OAuthMC OpenAPI specification
Download the raw specification: openapi.yaml.
openapi: 3.1.0
info:
title: OAuthMC API
version: 0.1.0
description: Ticket lifecycle and code redemption API for OAuthMC (code mode and link mode).
license:
name: MIT
url: https://opensource.org/licenses/MIT
servers:
- url: http://127.0.0.1:8080
security:
- bearerAuth: []
paths:
/healthz:
get:
summary: Liveness probe
security: []
responses:
"200":
description: Service is running
content:
application/json:
schema:
type: object
required: [ok]
properties:
ok:
type: boolean
const: true
/v1/tickets:
post:
summary: Create a verification ticket
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/CreateTicketRequest"
responses:
"201":
description: Ticket created
content:
application/json:
schema:
$ref: "#/components/schemas/TicketCreatedResponse"
"400":
$ref: "#/components/responses/ErrorResponse"
"401":
$ref: "#/components/responses/ErrorResponse"
"408":
description: Timed out reading request body
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"409":
description: Exclusive ticket requested while another open ticket exists for the name
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"413":
$ref: "#/components/responses/ErrorResponse"
"422":
$ref: "#/components/responses/ErrorResponse"
"503":
description: Global or per-key stored ticket limit reached (error code ticket_limit)
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/v1/tickets/{id}:
parameters:
- name: id
in: path
required: true
schema:
type: string
get:
summary: Get ticket status
responses:
"200":
description: Current ticket status (UUID is never returned here)
content:
application/json:
schema:
$ref: "#/components/schemas/TicketStatusResponse"
"401":
$ref: "#/components/responses/ErrorResponse"
"404":
$ref: "#/components/responses/ErrorResponse"
delete:
summary: Delete a ticket
responses:
"204":
description: Ticket deleted
"401":
$ref: "#/components/responses/ErrorResponse"
"404":
$ref: "#/components/responses/ErrorResponse"
/v1/tickets/{id}/redeem:
parameters:
- name: id
in: path
required: true
schema:
type: string
post:
summary: Redeem a verification code
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [code]
additionalProperties: false
properties:
code:
type: string
description: Case-insensitive 8-character code, with or without dash
responses:
"200":
description: Verification succeeded
content:
application/json:
schema:
$ref: "#/components/schemas/RedeemResponse"
"400":
$ref: "#/components/responses/ErrorResponse"
"401":
$ref: "#/components/responses/ErrorResponse"
"404":
$ref: "#/components/responses/ErrorResponse"
"408":
description: Timed out reading request body
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"409":
description: Ticket is not in joined state
content:
application/json:
schema:
$ref: "#/components/schemas/NotRedeemableError"
"413":
$ref: "#/components/responses/ErrorResponse"
"422":
description: Incorrect verification code
content:
application/json:
schema:
$ref: "#/components/schemas/WrongCodeError"
components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
responses:
ErrorResponse:
description: Error response
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
schemas:
TicketStatus:
type: string
enum: [pending, joined, redeemed, expired, locked]
TicketMessages:
type: object
additionalProperties: false
properties:
code:
type: string
minLength: 1
maxLength: 512
unverified:
type: string
minLength: 1
maxLength: 512
dialog_title:
type: string
minLength: 1
maxLength: 512
dialog_code:
type: string
minLength: 1
maxLength: 512
link:
type: string
minLength: 1
maxLength: 512
open_link:
type: string
minLength: 1
maxLength: 512
copy_code:
type: string
minLength: 1
maxLength: 512
verified:
type: string
minLength: 1
maxLength: 512
expired:
type: string
minLength: 1
maxLength: 512
locked:
type: string
minLength: 1
maxLength: 512
replaced:
type: string
minLength: 1
maxLength: 512
CreateTicketRequest:
type: object
required: [name]
additionalProperties: false
properties:
name:
type: string
pattern: "^[A-Za-z0-9_]{1,16}$"
mode:
type: string
enum: [code, link]
default: code
link_url:
type: string
minLength: 1
maxLength: 512
description: Required when mode is "link" and forbidden otherwise. Template URL starting with https:// (or http:// when OAUTHMC_ALLOW_HTTP_LINKS=1) containing both {ticket} and {code}; after substituting both placeholders, the result must have a valid host and contain only RFC 3986 URI characters (unreserved, reserved, or %HH).
ttl_seconds:
type: integer
minimum: 1
max_attempts:
type: integer
minimum: 1
exclusive:
type: boolean
messages:
$ref: "#/components/schemas/TicketMessages"
metadata:
type: object
additionalProperties: true
description: Opaque JSON object, at most 1024 serialized bytes
TicketCreatedResponse:
type: object
required: [id, name, address, mode, status, expires_at, max_attempts, exclusive, metadata]
properties:
id:
type: string
name:
type: string
address:
type: [string, "null"]
mode:
type: string
enum: [code, link]
status:
$ref: "#/components/schemas/TicketStatus"
expires_at:
type: string
format: date-time
max_attempts:
type: integer
exclusive:
type: boolean
metadata:
type: [object, "null"]
TicketStatusResponse:
type: object
required: [id, name, mode, status, expires_at, attempts_left, metadata]
properties:
id:
type: string
name:
type: string
mode:
type: string
enum: [code, link]
status:
$ref: "#/components/schemas/TicketStatus"
expires_at:
type: string
format: date-time
attempts_left:
type: integer
metadata:
type: [object, "null"]
RedeemResponse:
type: object
required: [uuid, name]
properties:
uuid:
type: string
format: uuid
name:
type: string
Error:
type: object
required: [error, message]
properties:
error:
type: string
message:
type: string
WrongCodeError:
allOf:
- $ref: "#/components/schemas/Error"
- type: object
required: [attempts_left]
properties:
attempts_left:
type: integer
NotRedeemableError:
allOf:
- $ref: "#/components/schemas/Error"
- type: object
required: [status]
properties:
status:
$ref: "#/components/schemas/TicketStatus"