{
  "openapi": "3.1.0",
  "info": {
    "title": "CI Connects API",
    "version": "1.3.0",
    "summary": "Read-only access to professional development certificates issued through CI Connects.",
    "description": "CI Connects is the professional development platform of Chadwick International. A partner system reads the certificates issued to staff, one record per person per event, and matches staff by school email address. Every certificate links to its PDF, the certificate as issued.\n\nA certificate that has been withdrawn is no longer valid. It is left out of the list of certificates and listed apart, by `GET /pd-certificates/withdrawn`, so a partner can remove or mark its copy.\n\nThe API key decides the environment. A sandbox key (`ci_test_`) returns sample records in the same format as production, with made-up people. A production key (`ci_live_`) returns the certificates issued to Chadwick International staff; Chadwick sends it to an approved partner separately."
  },
  "externalDocs": {
    "description": "Guides, examples and an API explorer.",
    "url": "https://ci-connects.org/developers"
  },
  "servers": [
    {
      "url": "https://ci-connects.org/api/v1",
      "description": "Sandbox and production share this address; the key decides which data is returned."
    }
  ],
  "security": [
    {
      "apiKey": []
    }
  ],
  "tags": [
    {
      "name": "Certificates",
      "description": "Certificates issued to staff, and those withdrawn."
    },
    {
      "name": "Events",
      "description": "The events certificates belong to."
    },
    {
      "name": "About",
      "description": "The API itself. No key is needed."
    }
  ],
  "paths": {
    "/": {
      "get": {
        "tags": [
          "About"
        ],
        "operationId": "getApiInfo",
        "summary": "What this API is, and where its description and documentation are",
        "security": [],
        "responses": {
          "200": {
            "description": "The API's name, version, endpoints and documentation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiInfo"
                }
              }
            }
          }
        }
      }
    },
    "/openapi.json": {
      "get": {
        "tags": [
          "About"
        ],
        "operationId": "getOpenApiDescription",
        "summary": "This description, as OpenAPI 3.1",
        "security": [],
        "responses": {
          "200": {
            "description": "The OpenAPI document. It can be imported into Postman, Insomnia or a code generator.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/pd-certificates": {
      "get": {
        "tags": [
          "Certificates"
        ],
        "operationId": "listPdCertificates",
        "summary": "List certificates",
        "description": "Returns issued certificates oldest first, by `issued_at` and then `certificate_number`. A withdrawn certificate is left out: `GET /pd-certificates/withdrawn` lists it. To read only what is new, pass the latest `issued_at` you hold as `issued_since`.\n\nA sync runs twice a day. First it reads the new certificates with `issued_since`, downloads each one's PDF from `pdf.url` in the same run, one at a time (fetching the certificate again for a fresh link after `410` `link_expired`), and stores each certificate by its number, replacing what it holds: a corrected certificate is issued again under the same number with a later `issued_at`. A PDF that answers `503` does not hold up the run: store the certificate, and ask for its PDF again on a later run. Then it reads `GET /pd-certificates/withdrawn` with `withdrawn_since`, and removes or marks each certificate that returns. Save the newest `issued_at` and the newest `withdrawn_at` only once every page of the run has been read and stored (certificates can share either to the millisecond). There is no webhook.",
        "parameters": [
          {
            "$ref": "#/components/parameters/issued_since"
          },
          {
            "$ref": "#/components/parameters/event_id"
          },
          {
            "$ref": "#/components/parameters/staff_email"
          },
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of issued certificates. The list may be empty.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CertificateList"
                },
                "example": {
                  "data": [
                    {
                      "certificate_number": "CIC-26-TEST-0001",
                      "staff": {
                        "email": "priya.nair@example.org",
                        "name": "Priya Nair"
                      },
                      "event": {
                        "id": "formative-assessment-workshop-2026",
                        "name": "Formative Assessment Workshop",
                        "start_date": "2026-09-23",
                        "end_date": "2026-09-23"
                      },
                      "role": "presenter",
                      "pd_hours": 1.25,
                      "issuer": "Chadwick International",
                      "signed_by": {
                        "name": "Jordan Hayes",
                        "title": "Head of Professional Learning"
                      },
                      "issued_at": "2026-09-24T02:05:11.140Z",
                      "status": "issued",
                      "withdrawn_at": null,
                      "pdf": {
                        "url": "https://ci-connects.org/api/v1/pd-certificates/CIC-26-TEST-0001/pdf?exp=1796119200&kid=fa768a00695b5965&sig=YSrzPag2y97e243aHNdka8qhmODl86yq2Eb-ctaN6xM",
                        "expires_at": "2026-12-01T10:00:00.000Z"
                      }
                    }
                  ],
                  "pagination": {
                    "limit": 1,
                    "returned": 1,
                    "has_more": true,
                    "next_cursor": "eyJhdCI6IjIwMjYtMDktMjRUMDI6MDU6MTEuMTQwWiIsIm4iOiJDSUMtMjYtVEVTVC0wMDAxIiwiZiI6ImZlNDRhOGNjY2Q4OSJ9"
                  },
                  "meta": {
                    "api_version": "v1",
                    "environment": "sandbox",
                    "request_id": "req_5e0c1f7a9b2d4c68a1f3",
                    "generated_at": "2026-12-01T08:30:00.000Z"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/pd-certificates/withdrawn": {
      "get": {
        "tags": [
          "Certificates"
        ],
        "operationId": "listWithdrawnPdCertificates",
        "summary": "List withdrawn certificates",
        "description": "Returns the certificates that have been withdrawn, in the order they were withdrawn: by `withdrawn_at`, then `certificate_number`. Each has `status` `withdrawn`, its `withdrawn_at`, and no PDF (`pdf` is null). A withdrawal is final, and why a certificate was withdrawn is not shared. A withdrawal is listed about two minutes after it is made; until then the certificate is listed as issued.\n\nAfter reading the new certificates with `issued_since`, pass the latest `withdrawn_at` you hold as `withdrawn_since`, and remove or mark each certificate returned. Save the newest `withdrawn_at` only once every page has been read (withdrawals can share a `withdrawn_at` to the millisecond).",
        "parameters": [
          {
            "$ref": "#/components/parameters/withdrawn_since"
          },
          {
            "$ref": "#/components/parameters/event_id"
          },
          {
            "$ref": "#/components/parameters/staff_email"
          },
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of withdrawn certificates. The list may be empty.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CertificateList"
                },
                "example": {
                  "data": [
                    {
                      "certificate_number": "CIC-26-TEST-0029",
                      "staff": {
                        "email": "hana.seo@example.org",
                        "name": "Hana Seo"
                      },
                      "event": {
                        "id": "formative-assessment-workshop-2026",
                        "name": "Formative Assessment Workshop",
                        "start_date": "2026-09-23",
                        "end_date": "2026-09-23"
                      },
                      "role": "attendee",
                      "pd_hours": 1.25,
                      "issuer": "Chadwick International",
                      "signed_by": {
                        "name": "Jordan Hayes",
                        "title": "Head of Professional Learning"
                      },
                      "issued_at": "2026-09-24T02:05:13.121Z",
                      "status": "withdrawn",
                      "withdrawn_at": "2026-11-20T03:00:00.000Z",
                      "pdf": null
                    },
                    {
                      "certificate_number": "CIC-26-TEST-0030",
                      "staff": {
                        "email": "priya.nair@example.org",
                        "name": "Priya Nair"
                      },
                      "event": {
                        "id": "inclusive-classroom-course-2026",
                        "name": "Inclusive Classroom Practice Course",
                        "start_date": "2026-09-02",
                        "end_date": "2026-10-28"
                      },
                      "role": "attendee",
                      "pd_hours": 7.5,
                      "issuer": "Chadwick International",
                      "signed_by": {
                        "name": "Jordan Hayes",
                        "title": "Head of Professional Learning"
                      },
                      "issued_at": "2026-10-29T06:40:24.491Z",
                      "status": "withdrawn",
                      "withdrawn_at": "2026-11-27T06:30:00.000Z",
                      "pdf": null
                    }
                  ],
                  "pagination": {
                    "limit": 100,
                    "returned": 2,
                    "has_more": false,
                    "next_cursor": null
                  },
                  "meta": {
                    "api_version": "v1",
                    "environment": "sandbox",
                    "request_id": "req_5e0c1f7a9b2d4c68a1f3",
                    "generated_at": "2026-12-01T08:30:00.000Z"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/pd-certificates/{certificate_number}": {
      "get": {
        "tags": [
          "Certificates"
        ],
        "operationId": "getPdCertificate",
        "summary": "Retrieve one certificate",
        "description": "Confirms a single certificate by its number, issued or withdrawn. A withdrawn certificate answers too, with `status` `withdrawn`, its `withdrawn_at` and no PDF: check `status` before you rely on a certificate.",
        "parameters": [
          {
            "name": "certificate_number",
            "in": "path",
            "required": true,
            "description": "The number printed on the certificate.",
            "schema": {
              "type": "string"
            },
            "example": "CIC-26-TEST-0001"
          }
        ],
        "responses": {
          "200": {
            "description": "The certificate.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CertificateResponse"
                },
                "examples": {
                  "issued": {
                    "summary": "An issued certificate",
                    "value": {
                      "data": {
                        "certificate_number": "CIC-26-TEST-0001",
                        "staff": {
                          "email": "priya.nair@example.org",
                          "name": "Priya Nair"
                        },
                        "event": {
                          "id": "formative-assessment-workshop-2026",
                          "name": "Formative Assessment Workshop",
                          "start_date": "2026-09-23",
                          "end_date": "2026-09-23"
                        },
                        "role": "presenter",
                        "pd_hours": 1.25,
                        "issuer": "Chadwick International",
                        "signed_by": {
                          "name": "Jordan Hayes",
                          "title": "Head of Professional Learning"
                        },
                        "issued_at": "2026-09-24T02:05:11.140Z",
                        "status": "issued",
                        "withdrawn_at": null,
                        "pdf": {
                          "url": "https://ci-connects.org/api/v1/pd-certificates/CIC-26-TEST-0001/pdf?exp=1796119200&kid=fa768a00695b5965&sig=YSrzPag2y97e243aHNdka8qhmODl86yq2Eb-ctaN6xM",
                          "expires_at": "2026-12-01T10:00:00.000Z"
                        }
                      },
                      "meta": {
                        "api_version": "v1",
                        "environment": "sandbox",
                        "request_id": "req_5e0c1f7a9b2d4c68a1f3",
                        "generated_at": "2026-12-01T08:30:00.000Z"
                      }
                    }
                  },
                  "withdrawn": {
                    "summary": "A withdrawn certificate",
                    "value": {
                      "data": {
                        "certificate_number": "CIC-26-TEST-0029",
                        "staff": {
                          "email": "hana.seo@example.org",
                          "name": "Hana Seo"
                        },
                        "event": {
                          "id": "formative-assessment-workshop-2026",
                          "name": "Formative Assessment Workshop",
                          "start_date": "2026-09-23",
                          "end_date": "2026-09-23"
                        },
                        "role": "attendee",
                        "pd_hours": 1.25,
                        "issuer": "Chadwick International",
                        "signed_by": {
                          "name": "Jordan Hayes",
                          "title": "Head of Professional Learning"
                        },
                        "issued_at": "2026-09-24T02:05:13.121Z",
                        "status": "withdrawn",
                        "withdrawn_at": "2026-11-20T03:00:00.000Z",
                        "pdf": null
                      },
                      "meta": {
                        "api_version": "v1",
                        "environment": "sandbox",
                        "request_id": "req_5e0c1f7a9b2d4c68a1f3",
                        "generated_at": "2026-12-01T08:30:00.000Z"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "A query parameter was given: this endpoint takes none.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_parameter",
                    "message": "Unknown parameter: x. This endpoint takes no parameters.",
                    "parameter": "x",
                    "request_id": "req_5e0c1f7a9b2d4c68a1f3"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "No certificate has this number.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "certificate_not_found",
                    "message": "No certificate has the number CIC-26-0000-0000.",
                    "request_id": "req_5e0c1f7a9b2d4c68a1f3"
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/pd-certificates/{certificate_number}/pdf": {
      "get": {
        "tags": [
          "Certificates"
        ],
        "operationId": "getPdCertificatePdf",
        "summary": "Download a certificate as PDF",
        "description": "The certificate as issued, as a PDF: the same record, with the signer's signature and, for a presenter, the titles they presented. Ask for it in either of two ways:\n\n- **By its link.** Every issued certificate in an answer has `pdf.url`. GET it as it is, with no key: its `exp`, `kid` and `sig` stand in for the key until `pdf.expires_at`. An expired link answers `410`; fetch the certificate again for a fresh one.\n- **With your key**, and no query parameters: `Authorization: Bearer <api_key>`.\n\nPDFs are counted in a rate limit of their own, 60 per minute per key; ask for them one at a time (several at once are answered `429`). Send the `ETag` of a PDF you hold as `If-None-Match` to get `304` when it has not changed.\n\n`503` `pdf_unavailable` leaves the certificate's record as it is: keep it, and ask for the PDF again at a later run. It can last, for a certificate holding a character or a signature the PDF cannot set.\n\nA withdrawn certificate has no PDF: by its link or with the key, it answers `404` with the code `certificate_withdrawn` (a certificate that is not listed at all answers `404` `certificate_not_found`). Remove or mark your copy.",
        "security": [
          {
            "apiKey": []
          },
          {}
        ],
        "parameters": [
          {
            "name": "certificate_number",
            "in": "path",
            "required": true,
            "description": "The number printed on the certificate.",
            "schema": {
              "type": "string"
            },
            "example": "CIC-26-TEST-0001"
          },
          {
            "$ref": "#/components/parameters/exp"
          },
          {
            "$ref": "#/components/parameters/kid"
          },
          {
            "$ref": "#/components/parameters/sig"
          },
          {
            "name": "If-None-Match",
            "in": "header",
            "description": "The `ETag` of the PDF you hold. If it is still the same, the answer is `304` with no body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The PDF.",
            "headers": {
              "Content-Disposition": {
                "$ref": "#/components/headers/ContentDisposition"
              },
              "ETag": {
                "$ref": "#/components/headers/ETag"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "304": {
            "description": "The PDF has not changed since the `ETag` sent in `If-None-Match`.",
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/ETag"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          },
          "400": {
            "description": "A link parameter is unknown, missing or damaged.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_parameter",
                    "message": "sig is missing. Use the certificate's pdf.url exactly as the API gave it, or send your API key instead of exp, kid and sig.",
                    "parameter": "sig",
                    "request_id": "req_5e0c1f7a9b2d4c68a1f3"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/LinkInvalid"
          },
          "404": {
            "description": "No certificate has this number (`certificate_not_found`), or the certificate has been withdrawn (`certificate_withdrawn`): a withdrawn certificate has no PDF. Remove or mark your copy.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "certificate_not_found": {
                    "summary": "No certificate has this number",
                    "value": {
                      "error": {
                        "code": "certificate_not_found",
                        "message": "No certificate has the number CIC-26-0000-0000.",
                        "request_id": "req_5e0c1f7a9b2d4c68a1f3"
                      }
                    }
                  },
                  "certificate_withdrawn": {
                    "summary": "The certificate has been withdrawn",
                    "value": {
                      "error": {
                        "code": "certificate_withdrawn",
                        "message": "This certificate has been withdrawn, so it has no PDF. Remove or mark your copy of it.",
                        "request_id": "req_5e0c1f7a9b2d4c68a1f3"
                      }
                    }
                  }
                }
              }
            }
          },
          "410": {
            "$ref": "#/components/responses/LinkExpired"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/PdfUnavailable"
          }
        }
      }
    },
    "/events": {
      "get": {
        "tags": [
          "Events"
        ],
        "operationId": "listEvents",
        "summary": "List events",
        "description": "Returns every event that has certificates, issued or withdrawn, earliest first. An event's `id` is the value `event_id` takes when listing certificates.",
        "responses": {
          "200": {
            "description": "The events.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EventList"
                },
                "example": {
                  "data": [
                    {
                      "id": "inclusive-classroom-course-2026",
                      "name": "Inclusive Classroom Practice Course",
                      "start_date": "2026-09-02",
                      "end_date": "2026-10-28",
                      "certificate_count": 7,
                      "withdrawn_count": 1
                    },
                    {
                      "id": "formative-assessment-workshop-2026",
                      "name": "Formative Assessment Workshop",
                      "start_date": "2026-09-23",
                      "end_date": "2026-09-23",
                      "certificate_count": 7,
                      "withdrawn_count": 1
                    },
                    {
                      "id": "ci-professional-learning-day-2026",
                      "name": "CI Professional Learning Day",
                      "start_date": "2026-10-16",
                      "end_date": "2026-10-16",
                      "certificate_count": 14,
                      "withdrawn_count": 0
                    }
                  ],
                  "meta": {
                    "api_version": "v1",
                    "environment": "sandbox",
                    "request_id": "req_5e0c1f7a9b2d4c68a1f3",
                    "generated_at": "2026-12-01T08:30:00.000Z"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "Send the key issued to you: `Authorization: Bearer <api_key>`."
      }
    },
    "parameters": {
      "issued_since": {
        "name": "issued_since",
        "in": "query",
        "description": "Only certificates issued after this time. Leave it out for a full export.",
        "schema": {
          "type": "string",
          "format": "date-time"
        },
        "example": "2026-10-01T00:00:00Z"
      },
      "withdrawn_since": {
        "name": "withdrawn_since",
        "in": "query",
        "description": "Only certificates withdrawn after this time. Leave it out for every withdrawn certificate.",
        "schema": {
          "type": "string",
          "format": "date-time"
        },
        "example": "2026-11-21T00:00:00Z"
      },
      "event_id": {
        "name": "event_id",
        "in": "query",
        "description": "Only certificates for this event.",
        "schema": {
          "type": "string"
        },
        "example": "formative-assessment-workshop-2026"
      },
      "staff_email": {
        "name": "staff_email",
        "in": "query",
        "description": "Only certificates held by this person. Upper and lower case are treated the same.",
        "schema": {
          "type": "string",
          "format": "email"
        },
        "example": "priya.nair@example.org"
      },
      "limit": {
        "name": "limit",
        "in": "query",
        "description": "Records per page.",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 500,
          "default": 100
        }
      },
      "cursor": {
        "name": "cursor",
        "in": "query",
        "description": "The `next_cursor` of the previous page of the same list. Keep the same `issued_since` (or `withdrawn_since`), `event_id` and `staff_email` while paging.",
        "schema": {
          "type": "string"
        }
      },
      "exp": {
        "name": "exp",
        "in": "query",
        "description": "Part of `pdf.url`: when the link stops working, in seconds since 1970 (UTC). Send `exp`, `kid` and `sig` together, as the link gives them, or none of them and your key instead.",
        "schema": {
          "type": "integer",
          "minimum": 1000000000,
          "maximum": 9999999999
        }
      },
      "kid": {
        "name": "kid",
        "in": "query",
        "description": "Part of `pdf.url`: which API key the link was made for. Revoking the key ends its links.",
        "schema": {
          "type": "string",
          "pattern": "^[0-9a-f]{16}$"
        }
      },
      "sig": {
        "name": "sig",
        "in": "query",
        "description": "Part of `pdf.url`: the link's signature. A link that has been changed in any way is refused.",
        "schema": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{43}$"
        }
      }
    },
    "headers": {
      "RequestId": {
        "description": "Identifies this request. Quote it when reporting a problem.",
        "schema": {
          "type": "string"
        }
      },
      "RateLimitLimit": {
        "description": "Requests allowed per minute for this key.",
        "schema": {
          "type": "integer"
        }
      },
      "RateLimitRemaining": {
        "description": "Requests left in the current minute.",
        "schema": {
          "type": "integer"
        }
      },
      "RateLimitReset": {
        "description": "Seconds until the current minute ends.",
        "schema": {
          "type": "integer"
        }
      },
      "RetryAfter": {
        "description": "Seconds to wait before the next request.",
        "schema": {
          "type": "integer"
        }
      },
      "ContentDisposition": {
        "description": "The PDF's file name: `attachment; filename=\"CI-Connects-<certificate_number>.pdf\"`.",
        "schema": {
          "type": "string"
        }
      },
      "ETag": {
        "description": "Identifies this version of the PDF. Send it back as `If-None-Match` to get `304` when nothing has changed.",
        "schema": {
          "type": "string"
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "A parameter is invalid.",
        "headers": {
          "X-Request-Id": {
            "$ref": "#/components/headers/RequestId"
          },
          "X-RateLimit-Limit": {
            "$ref": "#/components/headers/RateLimitLimit"
          },
          "X-RateLimit-Remaining": {
            "$ref": "#/components/headers/RateLimitRemaining"
          },
          "X-RateLimit-Reset": {
            "$ref": "#/components/headers/RateLimitReset"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "error": {
                "code": "invalid_parameter",
                "message": "limit must be a whole number from 1 to 500.",
                "parameter": "limit",
                "request_id": "req_5e0c1f7a9b2d4c68a1f3"
              }
            }
          }
        }
      },
      "Unauthorized": {
        "description": "The key is missing, invalid or revoked.",
        "headers": {
          "X-Request-Id": {
            "$ref": "#/components/headers/RequestId"
          },
          "WWW-Authenticate": {
            "description": "The authentication scheme to use.",
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "error": {
                "code": "invalid_api_key",
                "message": "This API key is not valid. It may have been revoked.",
                "request_id": "req_5e0c1f7a9b2d4c68a1f3"
              }
            }
          }
        }
      },
      "RateLimited": {
        "description": "Too many requests from this key, or several PDFs asked for at once.",
        "headers": {
          "X-Request-Id": {
            "$ref": "#/components/headers/RequestId"
          },
          "X-RateLimit-Limit": {
            "$ref": "#/components/headers/RateLimitLimit"
          },
          "X-RateLimit-Remaining": {
            "$ref": "#/components/headers/RateLimitRemaining"
          },
          "X-RateLimit-Reset": {
            "$ref": "#/components/headers/RateLimitReset"
          },
          "Retry-After": {
            "$ref": "#/components/headers/RetryAfter"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "error": {
                "code": "rate_limited",
                "message": "Too many requests. Wait for the time given in the Retry-After header.",
                "request_id": "req_5e0c1f7a9b2d4c68a1f3"
              }
            }
          }
        }
      },
      "ServerError": {
        "description": "Something went wrong on our side. Retry at the next scheduled run.",
        "headers": {
          "X-Request-Id": {
            "$ref": "#/components/headers/RequestId"
          },
          "X-RateLimit-Limit": {
            "$ref": "#/components/headers/RateLimitLimit"
          },
          "X-RateLimit-Remaining": {
            "$ref": "#/components/headers/RateLimitRemaining"
          },
          "X-RateLimit-Reset": {
            "$ref": "#/components/headers/RateLimitReset"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "error": {
                "code": "internal_error",
                "message": "Something went wrong on our side. Retry at your next scheduled run.",
                "request_id": "req_5e0c1f7a9b2d4c68a1f3"
              }
            }
          }
        }
      },
      "Unavailable": {
        "description": "The service is temporarily unavailable. Retry at the next scheduled run.",
        "headers": {
          "X-Request-Id": {
            "$ref": "#/components/headers/RequestId"
          },
          "X-RateLimit-Limit": {
            "$ref": "#/components/headers/RateLimitLimit"
          },
          "X-RateLimit-Remaining": {
            "$ref": "#/components/headers/RateLimitRemaining"
          },
          "X-RateLimit-Reset": {
            "$ref": "#/components/headers/RateLimitReset"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "error": {
                "code": "service_unavailable",
                "message": "The service is temporarily unavailable. Retry at your next scheduled run.",
                "request_id": "req_5e0c1f7a9b2d4c68a1f3"
              }
            }
          }
        }
      },
      "LinkInvalid": {
        "description": "The PDF link is not valid: it was changed, or the key it was made for has been revoked.",
        "headers": {
          "X-Request-Id": {
            "$ref": "#/components/headers/RequestId"
          },
          "X-RateLimit-Limit": {
            "$ref": "#/components/headers/RateLimitLimit"
          },
          "X-RateLimit-Remaining": {
            "$ref": "#/components/headers/RateLimitRemaining"
          },
          "X-RateLimit-Reset": {
            "$ref": "#/components/headers/RateLimitReset"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "error": {
                "code": "link_invalid",
                "message": "This PDF link is not valid. Fetch the certificate again for a fresh pdf.url.",
                "request_id": "req_5e0c1f7a9b2d4c68a1f3"
              }
            }
          }
        }
      },
      "LinkExpired": {
        "description": "The PDF link has expired. Fetch the certificate again for a fresh one.",
        "headers": {
          "X-Request-Id": {
            "$ref": "#/components/headers/RequestId"
          },
          "X-RateLimit-Limit": {
            "$ref": "#/components/headers/RateLimitLimit"
          },
          "X-RateLimit-Remaining": {
            "$ref": "#/components/headers/RateLimitRemaining"
          },
          "X-RateLimit-Reset": {
            "$ref": "#/components/headers/RateLimitReset"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "error": {
                "code": "link_expired",
                "message": "This PDF link has expired. Fetch the certificate again for a fresh pdf.url.",
                "request_id": "req_5e0c1f7a9b2d4c68a1f3"
              }
            }
          }
        }
      },
      "PdfUnavailable": {
        "description": "The PDF cannot be made (`pdf_unavailable`): PDFs are switched off for a while, or the certificate holds a character or a signature the PDF cannot set, which can last. The record is unaffected: keep it and ask for the PDF again at a later run. Or the service is unavailable (`service_unavailable`): retry at the next scheduled run.",
        "headers": {
          "X-Request-Id": {
            "$ref": "#/components/headers/RequestId"
          },
          "X-RateLimit-Limit": {
            "$ref": "#/components/headers/RateLimitLimit"
          },
          "X-RateLimit-Remaining": {
            "$ref": "#/components/headers/RateLimitRemaining"
          },
          "X-RateLimit-Reset": {
            "$ref": "#/components/headers/RateLimitReset"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "error": {
                "code": "pdf_unavailable",
                "message": "This certificate's PDF cannot be made now; its record is unaffected. Keep the record and ask for the PDF again at a later run.",
                "request_id": "req_5e0c1f7a9b2d4c68a1f3"
              }
            }
          }
        }
      }
    },
    "schemas": {
      "Certificate": {
        "type": "object",
        "description": "One certificate for one person at one event. An issued certificate is not edited afterwards: a corrected one is issued again under the same number, with a later `issued_at`. A certificate can also be withdrawn, for good: it then has `status` `withdrawn`, its `withdrawn_at`, and no PDF.",
        "additionalProperties": false,
        "required": [
          "certificate_number",
          "staff",
          "event",
          "role",
          "pd_hours",
          "issuer",
          "signed_by",
          "issued_at",
          "status",
          "withdrawn_at",
          "pdf"
        ],
        "properties": {
          "certificate_number": {
            "type": "string",
            "pattern": "^CIC-\\d{2}-[0-9A-Z]{4}-[0-9A-Z]{4}$",
            "description": "Unique for each person and event. Use it to avoid importing a record twice."
          },
          "staff": {
            "$ref": "#/components/schemas/Staff"
          },
          "event": {
            "$ref": "#/components/schemas/CertificateEvent"
          },
          "role": {
            "type": "string",
            "enum": [
              "attendee",
              "presenter"
            ],
            "description": "What the person did at the event."
          },
          "pd_hours": {
            "type": "number",
            "minimum": 0,
            "description": "The PD hours on the certificate. May include decimals, such as 1.25."
          },
          "issuer": {
            "type": "string",
            "description": "The school that issued the certificate."
          },
          "signed_by": {
            "$ref": "#/components/schemas/Signatory"
          },
          "issued_at": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 timestamp in UTC."
          },
          "status": {
            "type": "string",
            "enum": [
              "issued",
              "withdrawn"
            ],
            "description": "`issued`, or `withdrawn`: the certificate is no longer valid. `GET /pd-certificates` returns issued certificates only, and `GET /pd-certificates/withdrawn` the withdrawn ones."
          },
          "withdrawn_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the certificate was withdrawn, in UTC. Null while it is issued."
          },
          "pdf": {
            "type": [
              "object",
              "null"
            ],
            "description": "Where to download the certificate as a PDF without your key, until `expires_at`. Treat the link like your key: anyone who has it can open the certificate. Null for a withdrawn certificate, which has no PDF, and while PDFs are switched off.",
            "additionalProperties": false,
            "required": [
              "url",
              "expires_at"
            ],
            "properties": {
              "url": {
                "type": "string",
                "format": "uri",
                "description": "GET it, with no key, for the PDF. Every answer within the same hour gives the same link."
              },
              "expires_at": {
                "type": "string",
                "format": "date-time",
                "description": "When the link stops working: one to two hours after it was given. Fetch the certificate again for a fresh one."
              }
            }
          }
        }
      },
      "Staff": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "email",
          "name"
        ],
        "properties": {
          "email": {
            "type": "string",
            "format": "email",
            "description": "The person's school email address, in lowercase. Use it to match staff."
          },
          "name": {
            "type": "string",
            "description": "The name as it appears on the certificate."
          }
        }
      },
      "CertificateEvent": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "name",
          "start_date",
          "end_date"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "A stable identifier for the event."
          },
          "name": {
            "type": "string",
            "description": "The event's name as it appears on the certificate."
          },
          "start_date": {
            "type": "string",
            "format": "date",
            "description": "YYYY-MM-DD, in Korea time."
          },
          "end_date": {
            "type": "string",
            "format": "date",
            "description": "YYYY-MM-DD, in Korea time."
          }
        }
      },
      "Signatory": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name",
          "title"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "The person who signed the certificate."
          },
          "title": {
            "type": "string",
            "description": "Their title, as printed on the certificate."
          }
        }
      },
      "Event": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "name",
          "start_date",
          "end_date",
          "certificate_count",
          "withdrawn_count"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "A stable identifier for the event."
          },
          "name": {
            "type": "string",
            "description": "The event's name as it appears on the certificate."
          },
          "start_date": {
            "type": "string",
            "format": "date",
            "description": "YYYY-MM-DD, in Korea time."
          },
          "end_date": {
            "type": "string",
            "format": "date",
            "description": "YYYY-MM-DD, in Korea time."
          },
          "certificate_count": {
            "type": "integer",
            "minimum": 0,
            "description": "How many of this event's issued certificates this API returns (in production, those issued to Chadwick International staff). Withdrawn certificates are not counted here."
          },
          "withdrawn_count": {
            "type": "integer",
            "minimum": 0,
            "description": "How many of this event's certificates have been withdrawn: those `GET /pd-certificates/withdrawn` returns for it."
          }
        }
      },
      "Pagination": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "limit",
          "returned",
          "has_more",
          "next_cursor"
        ],
        "properties": {
          "limit": {
            "type": "integer",
            "description": "The page size used."
          },
          "returned": {
            "type": "integer",
            "description": "How many records this page holds."
          },
          "has_more": {
            "type": "boolean",
            "description": "Whether another page follows."
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "Pass this as `cursor` for the next page. Null on the last page."
          }
        }
      },
      "Meta": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "api_version",
          "environment",
          "request_id",
          "generated_at"
        ],
        "properties": {
          "api_version": {
            "type": "string",
            "enum": [
              "v1"
            ]
          },
          "environment": {
            "type": "string",
            "enum": [
              "sandbox",
              "production"
            ],
            "description": "Which data this answer holds. It follows from the key."
          },
          "request_id": {
            "type": "string",
            "description": "Identifies this request. Quote it when reporting a problem."
          },
          "generated_at": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 timestamp in UTC."
          }
        }
      },
      "CertificateList": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "data",
          "pagination",
          "meta"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Certificate"
            }
          },
          "pagination": {
            "$ref": "#/components/schemas/Pagination"
          },
          "meta": {
            "$ref": "#/components/schemas/Meta"
          }
        }
      },
      "CertificateResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "data",
          "meta"
        ],
        "properties": {
          "data": {
            "$ref": "#/components/schemas/Certificate"
          },
          "meta": {
            "$ref": "#/components/schemas/Meta"
          }
        }
      },
      "EventList": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "data",
          "meta"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Event"
            }
          },
          "meta": {
            "$ref": "#/components/schemas/Meta"
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "code",
              "message",
              "request_id"
            ],
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "missing_api_key",
                  "invalid_api_key",
                  "invalid_parameter",
                  "invalid_cursor",
                  "certificate_not_found",
                  "not_found",
                  "method_not_allowed",
                  "rate_limited",
                  "internal_error",
                  "service_unavailable",
                  "link_invalid",
                  "link_expired",
                  "pdf_unavailable",
                  "certificate_withdrawn"
                ],
                "description": "A stable code to act on."
              },
              "message": {
                "type": "string",
                "description": "A sentence for the developer reading the log."
              },
              "parameter": {
                "type": "string",
                "description": "The parameter at fault, when there is one."
              },
              "request_id": {
                "type": "string",
                "description": "Identifies this request. Quote it when reporting a problem."
              }
            }
          }
        }
      },
      "ApiInfo": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name",
          "version",
          "base_url",
          "authentication",
          "openapi",
          "documentation",
          "endpoints"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "base_url": {
            "type": "string",
            "format": "uri"
          },
          "authentication": {
            "type": "string"
          },
          "openapi": {
            "type": "string",
            "format": "uri"
          },
          "documentation": {
            "type": "string",
            "format": "uri",
            "description": "Guides, examples and an API explorer, for people."
          },
          "endpoints": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      }
    }
  }
}
