{
  "openapi": "3.1.0",
  "info": {
    "title": "Vega Access API",
    "description": "Vega Access connects property access-control systems to partner platforms.\nAuthenticate with OAuth2 (authorization code), then call the lock and access-code endpoints\nwith `Authorization: Bearer <access_token>`. Results of asynchronous operations are delivered\nto your registered webhook.",
    "version": "0.1.0"
  },
  "paths": {
    "/oauth/authorize": {
      "get": {
        "tags": [
          "OAuth2"
        ],
        "summary": "Start authorization (login + consent page)",
        "operationId": "authorize_oauth_authorize_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/oauth/token": {
      "post": {
        "tags": [
          "OAuth2"
        ],
        "summary": "Exchange an authorization code or refresh token",
        "operationId": "token_oauth_token_post",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        }
      }
    },
    "/oauth/revoke": {
      "post": {
        "tags": [
          "OAuth2"
        ],
        "summary": "Revoke a refresh or access token (RFC 7009)",
        "operationId": "revoke_oauth_revoke_post",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        }
      }
    },
    "/locks": {
      "get": {
        "tags": [
          "Locks"
        ],
        "summary": "List all locks the account can access",
        "operationId": "list_locks_locks_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        }
      }
    },
    "/locks/{lock_id}": {
      "get": {
        "tags": [
          "Locks"
        ],
        "summary": "Get one lock",
        "operationId": "get_lock_locks__lock_id__get",
        "parameters": [
          {
            "name": "lock_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Lock Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/locks/{lock_id}/actions": {
      "post": {
        "tags": [
          "Locks"
        ],
        "summary": "Lock or unlock; result follows as lock.action_completed",
        "operationId": "lock_action_locks__lock_id__actions_post",
        "parameters": [
          {
            "name": "lock_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Lock Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ActionIn"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/actions/{action_id}": {
      "get": {
        "tags": [
          "Locks"
        ],
        "summary": "Get the status of a lock action",
        "operationId": "get_action_actions__action_id__get",
        "parameters": [
          {
            "name": "action_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Action Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/locks/{lock_id}/access_codes": {
      "get": {
        "tags": [
          "Access codes"
        ],
        "summary": "List codes on a lock",
        "operationId": "list_codes_locks__lock_id__access_codes_get",
        "parameters": [
          {
            "name": "lock_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Lock Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Access codes"
        ],
        "summary": "Create a PIN code; result follows as access_code.created",
        "operationId": "create_code_locks__lock_id__access_codes_post",
        "parameters": [
          {
            "name": "lock_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Lock Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CodeIn"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/access_codes/{access_code_id}": {
      "get": {
        "tags": [
          "Access codes"
        ],
        "summary": "Get one code",
        "operationId": "get_code_access_codes__access_code_id__get",
        "parameters": [
          {
            "name": "access_code_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Access Code Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Access codes"
        ],
        "summary": "Change PIN, name or schedule; result follows as access_code.updated",
        "operationId": "patch_code_access_codes__access_code_id__patch",
        "parameters": [
          {
            "name": "access_code_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Access Code Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CodePatch"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Access codes"
        ],
        "summary": "Remove a code; result follows as access_code.deleted",
        "operationId": "delete_code_access_codes__access_code_id__delete",
        "parameters": [
          {
            "name": "access_code_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Access Code Id"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/webhooks": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Show the registered webhook",
        "operationId": "list_webhooks_webhooks_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Register (or replace) the single webhook endpoint for this environment",
        "operationId": "register_webhook_webhooks_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookIn"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/webhooks/{webhook_id}": {
      "delete": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Disable the webhook",
        "operationId": "delete_webhook_webhooks__webhook_id__delete",
        "parameters": [
          {
            "name": "webhook_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Webhook Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/health": {
      "get": {
        "tags": [
          "Service"
        ],
        "summary": "Liveness check",
        "operationId": "health_health_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ActionIn": {
        "properties": {
          "action": {
            "type": "string",
            "enum": [
              "lock",
              "unlock"
            ],
            "title": "Action"
          },
          "custom_id": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 128
              },
              {
                "type": "null"
              }
            ],
            "title": "Custom Id"
          }
        },
        "type": "object",
        "required": [
          "action"
        ],
        "title": "ActionIn"
      },
      "CodeIn": {
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 100,
            "minLength": 1,
            "title": "Name"
          },
          "code": {
            "type": "string",
            "title": "Code",
            "description": "4-8 digits, unique per property"
          },
          "starts_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Starts At"
          },
          "ends_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ends At"
          }
        },
        "type": "object",
        "required": [
          "name",
          "code"
        ],
        "title": "CodeIn"
      },
      "CodePatch": {
        "properties": {
          "name": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 100,
                "minLength": 1
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "code": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Code"
          },
          "starts_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Starts At"
          },
          "ends_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ends At"
          }
        },
        "type": "object",
        "title": "CodePatch"
      },
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
          }
        },
        "type": "object",
        "title": "HTTPValidationError"
      },
      "ValidationError": {
        "properties": {
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "type": "array",
            "title": "Location"
          },
          "msg": {
            "type": "string",
            "title": "Message"
          },
          "type": {
            "type": "string",
            "title": "Error Type"
          },
          "input": {
            "title": "Input"
          },
          "ctx": {
            "type": "object",
            "title": "Context"
          }
        },
        "type": "object",
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError"
      },
      "WebhookIn": {
        "properties": {
          "url": {
            "type": "string",
            "maxLength": 2048,
            "title": "Url"
          },
          "events": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Events",
            "description": "Event types to receive; empty = all"
          }
        },
        "type": "object",
        "required": [
          "url"
        ],
        "title": "WebhookIn"
      }
    }
  },
  "servers": [
    {
      "url": "https://api.vhostico.com"
    }
  ]
}