{
  "openapi": "3.1.0",
  "info": {
    "title": "Allveta API",
    "version": "1.0.0",
    "summary": "People, trainings, results, Verify and certificates for your organization.",
    "description": "Every call needs an API key from Organization › API in Allveta (admins only), sent as `Authorization: Bearer <key>`. Each key has its own permissions. The limit is 600 calls a minute per key; over it you get 429 with Retry-After. Lists are paged with a cursor. A person's result appears only when the organization shows individual question results.",
    "contact": {
      "name": "Allveta support",
      "url": "https://allveta.com/developers"
    }
  },
  "servers": [
    {
      "url": "https://app.allveta.com/v1/api"
    }
  ],
  "security": [
    {
      "apiKey": []
    }
  ],
  "tags": [
    {
      "name": "People"
    },
    {
      "name": "Trainings"
    },
    {
      "name": "Results"
    },
    {
      "name": "Certificates"
    }
  ],
  "paths": {
    "/people": {
      "get": {
        "tags": [
          "People"
        ],
        "operationId": "listPeople",
        "summary": "List the people register",
        "x-scopes": [
          "results:read"
        ],
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "The nextCursor from the previous page.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Items per page, 1–200.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "active",
                "left"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "nextCursor"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Person"
                      }
                    },
                    "nextCursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/LicenseRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/people/{personId}": {
      "get": {
        "tags": [
          "People"
        ],
        "operationId": "getPerson",
        "summary": "A person with their trainings and certificates",
        "x-scopes": [
          "results:read"
        ],
        "parameters": [
          {
            "name": "personId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersonDetail"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/LicenseRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/quizzes": {
      "get": {
        "tags": [
          "Trainings"
        ],
        "operationId": "listQuizzes",
        "summary": "The organization's knowledge tests",
        "x-scopes": [
          "content:read"
        ],
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "The nextCursor from the previous page.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Items per page, 1–200.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "nextCursor"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Quiz"
                      }
                    },
                    "nextCursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/LicenseRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/trainings": {
      "get": {
        "tags": [
          "Trainings"
        ],
        "operationId": "listTrainings",
        "summary": "Sessions and courses",
        "x-scopes": [
          "content:read"
        ],
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "The nextCursor from the previous page.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Items per page, 1–200.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "nextCursor"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Training"
                      }
                    },
                    "nextCursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/LicenseRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "tags": [
          "Trainings"
        ],
        "operationId": "createTraining",
        "summary": "Create a session from a knowledge test",
        "x-scopes": [
          "content:write"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewTraining"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Training"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/LicenseRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/trainings/{trainingId}": {
      "get": {
        "tags": [
          "Trainings"
        ],
        "operationId": "getTraining",
        "summary": "A session or course",
        "x-scopes": [
          "content:read"
        ],
        "parameters": [
          {
            "name": "trainingId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Training"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/LicenseRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/trainings/{trainingId}/participants": {
      "get": {
        "tags": [
          "Results"
        ],
        "operationId": "listParticipants",
        "summary": "Status per person in a session or course",
        "x-scopes": [
          "results:read"
        ],
        "parameters": [
          {
            "name": "trainingId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "The nextCursor from the previous page.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Items per page, 1–200.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "personalResults",
                    "data",
                    "nextCursor"
                  ],
                  "properties": {
                    "personalResults": {
                      "type": "boolean",
                      "description": "Whether results per person are included."
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Participant"
                      }
                    },
                    "nextCursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/LicenseRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/trainings/{trainingId}/assignments": {
      "post": {
        "tags": [
          "Trainings"
        ],
        "operationId": "assignTraining",
        "summary": "Assign people, departments or addresses and invite them",
        "x-scopes": [
          "assign:write"
        ],
        "parameters": [
          {
            "name": "trainingId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Assignment"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AssignmentResult"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/LicenseRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/verify": {
      "get": {
        "tags": [
          "Results"
        ],
        "operationId": "getVerify",
        "summary": "The organization's Verify score, group level only",
        "x-scopes": [
          "results:read"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Verify"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/LicenseRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/certificates": {
      "get": {
        "tags": [
          "Certificates"
        ],
        "operationId": "listCertificates",
        "summary": "Issued certificates",
        "x-scopes": [
          "results:read"
        ],
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "The nextCursor from the previous page.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Items per page, 1–200.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "valid",
                "expiring",
                "expired",
                "revoked"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "nextCursor"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Certificate"
                      }
                    },
                    "nextCursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/LicenseRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "tags": [
          "Certificates"
        ],
        "operationId": "issueCertificate",
        "summary": "Issue a certificate the person has earned",
        "x-scopes": [
          "certificates:write"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "trainingId",
                  "personId"
                ],
                "properties": {
                  "trainingId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "personId": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Already issued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IssuedCertificate"
                }
              }
            }
          },
          "201": {
            "description": "Issued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IssuedCertificate"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/LicenseRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    }
  },
  "webhooks": {
    "training.completed": {
      "post": {
        "summary": "The training.completed event",
        "description": "Signed with the webhook's secret: the allveta-signature header is t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<body>\">. Answer 2xx within 10 seconds. Failed deliveries are retried with backoff for about two days.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Event"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Received"
          }
        }
      }
    },
    "training.passed": {
      "post": {
        "summary": "The training.passed event",
        "description": "Signed with the webhook's secret: the allveta-signature header is t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<body>\">. Answer 2xx within 10 seconds. Failed deliveries are retried with backoff for about two days.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Event"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Received"
          }
        }
      }
    },
    "training.failed": {
      "post": {
        "summary": "The training.failed event",
        "description": "Signed with the webhook's secret: the allveta-signature header is t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<body>\">. Answer 2xx within 10 seconds. Failed deliveries are retried with backoff for about two days.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Event"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Received"
          }
        }
      }
    },
    "certificate.issued": {
      "post": {
        "summary": "The certificate.issued event",
        "description": "Signed with the webhook's secret: the allveta-signature header is t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<body>\">. Answer 2xx within 10 seconds. Failed deliveries are retried with backoff for about two days.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Event"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Received"
          }
        }
      }
    },
    "certificate.expiring": {
      "post": {
        "summary": "The certificate.expiring event",
        "description": "Signed with the webhook's secret: the allveta-signature header is t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<body>\">. Answer 2xx within 10 seconds. Failed deliveries are retried with backoff for about two days.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Event"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Received"
          }
        }
      }
    },
    "certificate.expired": {
      "post": {
        "summary": "The certificate.expired event",
        "description": "Signed with the webhook's secret: the allveta-signature header is t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<body>\">. Answer 2xx within 10 seconds. Failed deliveries are retried with backoff for about two days.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Event"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Received"
          }
        }
      }
    },
    "certificate.revoked": {
      "post": {
        "summary": "The certificate.revoked event",
        "description": "Signed with the webhook's secret: the allveta-signature header is t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<body>\">. Answer 2xx within 10 seconds. Failed deliveries are retried with backoff for about two days.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Event"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Received"
          }
        }
      }
    },
    "person.added": {
      "post": {
        "summary": "The person.added event",
        "description": "Signed with the webhook's secret: the allveta-signature header is t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<body>\">. Answer 2xx within 10 seconds. Failed deliveries are retried with backoff for about two days.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Event"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Received"
          }
        }
      }
    },
    "person.removed": {
      "post": {
        "summary": "The person.removed event",
        "description": "Signed with the webhook's secret: the allveta-signature header is t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<body>\">. Answer 2xx within 10 seconds. Failed deliveries are retried with backoff for about two days.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Event"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Received"
          }
        }
      }
    },
    "knowledge.changed": {
      "post": {
        "summary": "The knowledge.changed event",
        "description": "Signed with the webhook's secret: the allveta-signature header is t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<body>\">. Answer 2xx within 10 seconds. Failed deliveries are retried with backoff for about two days.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Event"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Received"
          }
        }
      }
    },
    "agent_test.requested": {
      "post": {
        "summary": "The agent_test.requested event",
        "description": "Signed with the webhook's secret: the allveta-signature header is t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<body>\">. Answer 2xx within 10 seconds. Failed deliveries are retried with backoff for about two days.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Event"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Received"
          }
        }
      }
    },
    "agent_test.passed": {
      "post": {
        "summary": "The agent_test.passed event",
        "description": "Signed with the webhook's secret: the allveta-signature header is t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<body>\">. Answer 2xx within 10 seconds. Failed deliveries are retried with backoff for about two days.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Event"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Received"
          }
        }
      }
    },
    "agent_test.failed": {
      "post": {
        "summary": "The agent_test.failed event",
        "description": "Signed with the webhook's secret: the allveta-signature header is t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<body>\">. Answer 2xx within 10 seconds. Failed deliveries are retried with backoff for about two days.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Event"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Received"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "An API key (oqk_…). Permissions: results:read, content:read, content:write, assign:write, certificates:write."
      }
    },
    "responses": {
      "BadRequest": {
        "description": "The request is not valid.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "No key, or the key is unknown, revoked or expired.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "LicenseRequired": {
        "description": "The organization's license has ended.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Forbidden": {
        "description": "The key lacks the permission (insufficient_scope).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "NotFound": {
        "description": "Not found in your organization.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Conflict": {
        "description": "Not possible right now, for example not_eligible.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "RateLimited": {
        "description": "More than 600 calls this minute.",
        "headers": {
          "Retry-After": {
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "Department": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          },
          {
            "type": "null"
          }
        ]
      },
      "Person": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "external": {
            "type": "boolean"
          },
          "department": {
            "$ref": "#/components/schemas/Department"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "left"
            ]
          },
          "leftAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "training": {
            "type": "string",
            "enum": [
              "valid",
              "expiring",
              "expired",
              "not_done"
            ]
          },
          "sessions": {
            "type": "integer"
          },
          "courses": {
            "type": "integer"
          },
          "certificates": {
            "type": "integer"
          },
          "lastActivity": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "since": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PersonDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Person"
          },
          {
            "type": "object",
            "properties": {
              "personalResults": {
                "type": "boolean"
              },
              "trainings": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/TrainingStatus"
                }
              }
            }
          }
        ]
      },
      "TrainingStatus": {
        "type": "object",
        "properties": {
          "trainingId": {
            "type": "string",
            "format": "uuid"
          },
          "kind": {
            "type": "string",
            "enum": [
              "session",
              "course"
            ]
          },
          "name": {
            "type": "string"
          },
          "assignedAt": {
            "type": "string",
            "format": "date-time"
          },
          "closesAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "not_started",
              "in_progress",
              "done"
            ]
          },
          "passed": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ]
          },
          "completedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "parts": {
            "type": "object",
            "properties": {
              "done": {
                "type": "integer"
              },
              "total": {
                "type": "integer"
              }
            }
          },
          "result": {
            "type": "object",
            "description": "Only when the organization shows individual question results.",
            "properties": {
              "percent": {
                "type": "integer"
              }
            }
          },
          "certificate": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/CertificateRef"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "Participant": {
        "allOf": [
          {
            "type": "object",
            "properties": {
              "person": {
                "type": "object",
                "properties": {
                  "id": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "name": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string"
                  },
                  "department": {
                    "$ref": "#/components/schemas/Department"
                  }
                }
              }
            }
          },
          {
            "$ref": "#/components/schemas/TrainingStatus"
          }
        ]
      },
      "CertificateRef": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "issuedAt": {
            "type": "string",
            "format": "date-time"
          },
          "validUntil": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "state": {
            "type": "string",
            "enum": [
              "valid",
              "expiring",
              "expired"
            ]
          }
        }
      },
      "Quiz": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "editedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "Training": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "kind": {
            "type": "string",
            "enum": [
              "session",
              "course"
            ]
          },
          "name": {
            "type": "string"
          },
          "quizId": {
            "type": "string",
            "format": "uuid"
          },
          "questionCount": {
            "type": "integer"
          },
          "parts": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "opensAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "closesAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "window": {
            "type": "string"
          },
          "passPercent": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "automatic": {
            "type": "boolean"
          },
          "counts": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "recipients": {
                    "type": "integer"
                  },
                  "notStarted": {
                    "type": "integer"
                  },
                  "inProgress": {
                    "type": "integer"
                  },
                  "done": {
                    "type": "integer"
                  },
                  "passed": {
                    "type": "integer"
                  }
                }
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "NewTraining": {
        "type": "object",
        "required": [
          "quizId"
        ],
        "properties": {
          "quizId": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "lang": {
            "type": "string",
            "examples": [
              "sv",
              "en"
            ]
          },
          "opensAt": {
            "type": "string",
            "format": "date-time"
          },
          "closesAt": {
            "type": "string",
            "format": "date-time"
          },
          "passPercent": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100
          },
          "attemptRule": {
            "type": "string",
            "enum": [
              "best",
              "first",
              "latest"
            ]
          },
          "maxAttempts": {
            "type": "integer"
          }
        }
      },
      "Assignment": {
        "type": "object",
        "description": "At least one of personIds, departmentIds and people. Up to 500 people.",
        "properties": {
          "personIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "departmentIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "people": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "email"
              ],
              "properties": {
                "email": {
                  "type": "string",
                  "format": "email"
                },
                "name": {
                  "type": "string"
                }
              }
            }
          },
          "invite": {
            "type": "boolean",
            "default": true,
            "description": "Send the invitation email right away."
          }
        }
      },
      "AssignmentResult": {
        "type": "object",
        "properties": {
          "added": {
            "type": "integer"
          },
          "invited": {
            "type": "integer"
          },
          "rejected": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "text": {
                  "type": "string"
                },
                "reason": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "Verify": {
        "type": "object",
        "description": "The share who have shown they know it after the last review, over the last twelve months. Never per person.",
        "properties": {
          "percent": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "previous": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "change": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "sessions": {
            "type": "integer"
          },
          "people": {
            "type": "integer"
          },
          "answers": {
            "type": "integer"
          },
          "from": {
            "type": "string",
            "format": "date-time"
          },
          "to": {
            "type": "string",
            "format": "date-time"
          },
          "expectedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "control": {
            "type": "object",
            "properties": {
              "percent": {
                "anyOf": [
                  {
                    "type": "integer"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "people": {
                "type": "integer"
              },
              "tested": {
                "type": "integer"
              },
              "kept": {
                "type": "integer"
              }
            }
          },
          "steps": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "days": {
                  "type": "integer"
                },
                "knows": {
                  "type": "integer"
                },
                "base": {
                  "type": "integer"
                },
                "percent": {
                  "anyOf": [
                    {
                      "type": "integer"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          },
          "areas": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "percent": {
                  "anyOf": [
                    {
                      "type": "integer"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "Certificate": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "person": {
            "type": "object",
            "properties": {
              "id": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "name": {
                "type": "string"
              },
              "email": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            }
          },
          "trainingId": {
            "type": "string",
            "format": "uuid"
          },
          "kind": {
            "type": "string",
            "enum": [
              "session",
              "course"
            ]
          },
          "title": {
            "type": "string"
          },
          "completedAt": {
            "type": "string",
            "format": "date-time"
          },
          "issuedAt": {
            "type": "string",
            "format": "date-time"
          },
          "validUntil": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "state": {
            "type": "string",
            "enum": [
              "valid",
              "expiring",
              "expired",
              "revoked"
            ]
          },
          "revokedAt": {
            "type": "string",
            "format": "date-time",
            "description": "Only on a revoked certificate. It is no longer valid, and its page says so."
          },
          "verifyUrl": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "IssuedCertificate": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "verifyUrl": {
            "type": "string",
            "format": "uri"
          },
          "issued": {
            "type": "boolean"
          }
        }
      },
      "Event": {
        "type": "object",
        "required": [
          "id",
          "type",
          "createdAt",
          "orgId",
          "data"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The same in every retry. Use it to drop duplicates."
          },
          "type": {
            "type": "string",
            "enum": [
              "training.completed",
              "training.passed",
              "training.failed",
              "certificate.issued",
              "certificate.expiring",
              "certificate.expired",
              "certificate.revoked",
              "person.added",
              "person.removed",
              "knowledge.changed",
              "agent_test.requested",
              "agent_test.passed",
              "agent_test.failed"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "orgId": {
            "type": "string"
          },
          "data": {
            "type": "object",
            "properties": {
              "person": {
                "type": "object",
                "properties": {
                  "id": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "name": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string"
                  }
                }
              },
              "training": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "kind": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  }
                }
              },
              "result": {
                "type": "object",
                "properties": {
                  "passed": {
                    "anyOf": [
                      {
                        "type": "boolean"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "attempt": {
                    "type": "integer"
                  },
                  "percent": {
                    "type": "integer"
                  },
                  "correct": {
                    "type": "integer"
                  },
                  "total": {
                    "type": "integer"
                  }
                }
              },
              "certificate": {
                "type": "object",
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "issuedAt": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "validUntil": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "revokedAt": {
                    "type": "string",
                    "format": "date-time",
                    "description": "Only on certificate.revoked."
                  },
                  "verifyUrl": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}