{
  "openapi": "3.1.0",
  "info": {
    "title": "NairaCheck CAC API",
    "description": "Search the Corporate Affairs Commission (CAC) public register for Nigerian companies, business names and incorporated trustees.",
    "contact": {
      "name": "NairaCheck API Support",
      "email": "api@nairacheck.com"
    },
    "license": {
      "name": "Proprietary"
    },
    "version": "1.0.0"
  },
  "paths": {
    "/v1/companies/search": {
      "post": {
        "tags": [
          "Company Search"
        ],
        "summary": "Search the CAC register",
        "description": "Search Nigeria's Corporate Affairs Commission register.\n\nMatches on the field selected by `search_type` and returns every entity the\nregister considers similar — a name search therefore returns near matches\nalongside exact ones. Results are ordered as the register returns them.\n\nIdentical searches are served from a short-lived cache; the `cached` field\ntells you which you received.",
        "operationId": "searchCompanies",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CompanySearchRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompanySearchResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The API key lacks the `cac:search` scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "The request body exceeds the size limit.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "The request payload failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Your plan's per-minute rate limit was exceeded. Honour `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "502": {
            "description": "The CAC register returned an unusable response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "The CAC register is unreachable or throttling. Retryable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "504": {
            "description": "The CAC register did not respond in time. Retryable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "Company": {
        "properties": {
          "approved_name": {
            "type": "string",
            "title": "Approved Name",
            "description": "Registered name as recorded by the CAC, whitespace-normalised.",
            "examples": [
              "ZENITH SUPPORT SERVICES LIMITED"
            ]
          },
          "rc_number": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Rc Number",
            "description": "Registration number. Null while an entity is still under registration.",
            "examples": [
              "1706475"
            ]
          },
          "company_id": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Company Id",
            "description": "The register's internal identifier for the entity.",
            "examples": [
              6519835
            ]
          },
          "entity_type": {
            "$ref": "#/components/schemas/EntityType",
            "description": "Normalised entity classification.",
            "examples": [
              "COMPANY"
            ]
          },
          "classification_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Classification Name",
            "description": "Raw classification as returned by the register, before normalisation.",
            "examples": [
              "COMPANY"
            ]
          },
          "classification_id": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Classification Id",
            "examples": [
              2
            ]
          },
          "nature_of_business": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Nature Of Business",
            "description": "Declared line of business. Frequently unspecified or null.",
            "examples": [
              "GENERAL CONTRACT AND MERCHANDISE"
            ]
          },
          "status": {
            "$ref": "#/components/schemas/RegistrationStatus",
            "description": "Registration status on the register.",
            "examples": [
              "ACTIVE"
            ]
          },
          "registration_date": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Registration Date",
            "description": "Date of registration, in UTC (RFC 3339).",
            "examples": [
              "2020-09-01T20:00:00Z"
            ]
          }
        },
        "type": "object",
        "required": [
          "approved_name",
          "entity_type",
          "status"
        ],
        "title": "Company",
        "description": "A single entity on the CAC register.\n\nFields are ``null`` where the register holds no value. Entities with status\n``UNDER_REGISTRATION`` have not yet been assigned an ``rc_number``.",
        "example": {
          "approved_name": "ZENITH SUPPORT SERVICES LIMITED",
          "classification_id": 2,
          "classification_name": "COMPANY",
          "company_id": 6519835,
          "entity_type": "COMPANY",
          "nature_of_business": "GENERAL CONTRACT AND MERCHANDISE",
          "rc_number": "1706475",
          "registration_date": "2020-09-01T20:00:00Z",
          "status": "ACTIVE"
        }
      },
      "CompanySearchRequest": {
        "properties": {
          "search_type": {
            "$ref": "#/components/schemas/SearchType",
            "description": "`ALL` searches every indexed field. `RC_NUMBER` matches the registration number, `AV_CODE` the availability code issued for a reserved name, and `APPROVED_NAME` the registered entity name.",
            "default": "ALL"
          },
          "search_term": {
            "type": "string",
            "maxLength": 200,
            "minLength": 2,
            "title": "Search Term",
            "description": "The value to search for. Leading and trailing whitespace is trimmed.",
            "examples": [
              "zenith"
            ]
          },
          "limit": {
            "type": "integer",
            "maximum": 100,
            "minimum": 1,
            "title": "Limit",
            "description": "Maximum number of records to return.",
            "default": 25
          },
          "offset": {
            "type": "integer",
            "minimum": 0,
            "title": "Offset",
            "description": "Number of records to skip, for paging through a result set.",
            "default": 0
          }
        },
        "type": "object",
        "required": [
          "search_term"
        ],
        "title": "CompanySearchRequest",
        "example": {
          "limit": 25,
          "offset": 0,
          "search_term": "zenith",
          "search_type": "ALL"
        }
      },
      "CompanySearchResponse": {
        "properties": {
          "request_id": {
            "type": "string",
            "title": "Request Id",
            "description": "Correlation id for this call; matches the X-Request-Id header.",
            "examples": [
              "req_9f4c2b7a8d1e4f60"
            ]
          },
          "search_type": {
            "$ref": "#/components/schemas/SearchType"
          },
          "search_term": {
            "type": "string",
            "title": "Search Term",
            "description": "The normalised term that was searched."
          },
          "cached": {
            "type": "boolean",
            "title": "Cached",
            "description": "True when served from NairaCheck's cache rather than a live register call.",
            "examples": [
              false
            ]
          },
          "pagination": {
            "$ref": "#/components/schemas/Pagination"
          },
          "data": {
            "items": {
              "$ref": "#/components/schemas/Company"
            },
            "type": "array",
            "title": "Data",
            "description": "Matching entities for the requested page."
          }
        },
        "type": "object",
        "required": [
          "request_id",
          "search_type",
          "search_term",
          "cached",
          "pagination",
          "data"
        ],
        "title": "CompanySearchResponse",
        "example": {
          "cached": false,
          "data": [
            {
              "approved_name": "ZENITH SUPPORT SERVICES LIMITED",
              "classification_id": 2,
              "classification_name": "COMPANY",
              "company_id": 6519835,
              "entity_type": "COMPANY",
              "nature_of_business": "GENERAL CONTRACT AND MERCHANDISE",
              "rc_number": "1706475",
              "registration_date": "2020-09-01T20:00:00Z",
              "status": "ACTIVE"
            }
          ],
          "pagination": {
            "has_more": true,
            "limit": 25,
            "offset": 0,
            "total": 28
          },
          "request_id": "req_9f4c2b7a8d1e4f60",
          "search_term": "zenith",
          "search_type": "ALL"
        }
      },
      "EntityType": {
        "type": "string",
        "enum": [
          "COMPANY",
          "BUSINESS_NAME",
          "INCORPORATED_TRUSTEES",
          "UNKNOWN"
        ],
        "title": "EntityType",
        "description": "Normalised form of the register's ``classificationName``.\n\n``INCORPORATED_TRUSTEES`` is the expanded form of the register's ``IT``\ncode — churches, NGOs and associations registered under Part F of CAMA."
      },
      "ErrorDetail": {
        "properties": {
          "type": {
            "type": "string",
            "title": "Type",
            "description": "Error family: authentication_error, invalid_request_error, rate_limit_error, upstream_error or api_error.",
            "examples": [
              "invalid_request_error"
            ]
          },
          "code": {
            "type": "string",
            "title": "Code",
            "description": "Stable machine-readable code. Safe to branch on.",
            "examples": [
              "search_term_too_short"
            ]
          },
          "message": {
            "type": "string",
            "title": "Message",
            "description": "Human-readable explanation. Do not parse.",
            "examples": [
              "search_term must be at least 2 characters."
            ]
          },
          "details": {
            "anyOf": [
              {
                "items": {
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Details",
            "description": "Field-level context, present on validation errors."
          },
          "request_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Request Id",
            "description": "Echoes the X-Request-Id response header. Quote this in support requests.",
            "examples": [
              "req_9f4c2b7a8d1e4f60"
            ]
          }
        },
        "type": "object",
        "required": [
          "type",
          "code",
          "message"
        ],
        "title": "ErrorDetail"
      },
      "ErrorResponse": {
        "properties": {
          "error": {
            "$ref": "#/components/schemas/ErrorDetail"
          }
        },
        "type": "object",
        "required": [
          "error"
        ],
        "title": "ErrorResponse"
      },
      "Pagination": {
        "properties": {
          "total": {
            "type": "integer",
            "title": "Total",
            "description": "Total matches found before pagination.",
            "examples": [
              28
            ]
          },
          "limit": {
            "type": "integer",
            "title": "Limit",
            "description": "Maximum records returned in this page.",
            "examples": [
              25
            ]
          },
          "offset": {
            "type": "integer",
            "title": "Offset",
            "description": "Zero-based index of the first record returned.",
            "examples": [
              0
            ]
          },
          "has_more": {
            "type": "boolean",
            "title": "Has More",
            "description": "True when further records are available at a higher offset.",
            "examples": [
              true
            ]
          }
        },
        "type": "object",
        "required": [
          "total",
          "limit",
          "offset",
          "has_more"
        ],
        "title": "Pagination",
        "description": "Offset pagination over a single upstream result set.",
        "example": {
          "has_more": true,
          "limit": 25,
          "offset": 0,
          "total": 28
        }
      },
      "RegistrationStatus": {
        "type": "string",
        "enum": [
          "ACTIVE",
          "INACTIVE",
          "UNDER_REGISTRATION",
          "UNKNOWN"
        ],
        "title": "RegistrationStatus"
      },
      "SearchType": {
        "type": "string",
        "enum": [
          "ALL",
          "RC_NUMBER",
          "AV_CODE",
          "APPROVED_NAME"
        ],
        "title": "SearchType",
        "description": "Which field of the register to match ``search_term`` against."
      }
    },
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Your NairaCheck API key, sent as `Authorization: Bearer nck_live_...`."
      }
    }
  },
  "tags": [
    {
      "name": "Company Search",
      "description": "Look up entities on the CAC public register."
    },
    {
      "name": "Service",
      "description": "Health and readiness probes."
    }
  ],
  "servers": [
    {
      "url": "https://api.nairacheck.com",
      "description": "production"
    }
  ],
  "security": [
    {
      "BearerAuth": []
    }
  ]
}
