{
  "openapi": "3.1.0",
  "info": {
    "title": "Consent evidence API",
    "version": "1.0.0",
    "description": "Read the consent records your account holds. Every answer is built by the same code the signed-in console uses, and a record that does not pass its integrity check is never returned (it is counted). A record is evidence of what a person agreed to and when — not a statement that a number may be contacted today. Nothing here is a legal assessment. A consent REPORTED with a write key (POST /consents) is recorded as caller-asserted and reported by an API key — a weaker claim than a consent this system showed and recorded itself, and weaker than a signed webhook — and every output says so."
  },
  "servers": [
    {
      "url": "https://leadconsentpro.com/api/v1"
    }
  ],
  "security": [
    {
      "apiKey": []
    }
  ],
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "An API key from Settings → API keys, sent as \"Authorization: Bearer lcp_…\". Scopes: records:read, certificates:read, exports:read, revocations:read, records:write, brands:write. A key belongs to the account: it keeps working when the person who created it leaves, until it is revoked or expires. 60 requests per minute per key."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          }
        }
      },
      "Record": {
        "type": "object",
        "description": "One record: the certificate facts (provenance and the bot-check fact as codes), the certificate document hash, and the public verification link.",
        "properties": {
          "facts": {
            "type": "object"
          },
          "documentHash": {
            "type": "string"
          },
          "verificationUrl": {
            "type": "string",
            "format": "uri"
          }
        }
      }
    }
  },
  "paths": {
    "/brands": {
      "get": {
        "summary": "The active brands this key may read",
        "x-scope": "records:read",
        "responses": {
          "200": {
            "description": "Brands"
          },
          "401": {
            "description": "invalid_key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Create a brand and get its install snippet",
        "x-scope": "brands:write",
        "description": "Does what an owner or admin’s \"Add a brand\" does: on the key’s own account, within the plan’s limit, with the starting wording (not reviewed by a lawyer). A key limited to some brands may not create brands. Not idempotent: after a lost response, list your brands before retrying. Body (JSON): legalName, domains (an array of hostnames, or one string), termsUrl, privacyUrl; campaignName optional. Hostnames that cannot be used are left out and listed in rejectedDomains of the 201. A 400 invalid_fields body is { error, missing: [\"legalName\" | \"domains\"], rejectedDomains, linksUnusable (true when termsUrl or privacyUrl cannot be used) }; a 400 unknown_field also lists the fields. \"domains\" as one string may be separated by newlines or commas.",
        "responses": {
          "201": {
            "description": "Created: { brandId, domains, rejectedDomains, wording: \"default_template_unreviewed\", installSnippet }. The wording is the starting template, not reviewed by a lawyer, until the owner publishes their own."
          },
          "400": {
            "description": "invalid_json | unknown_field | domains_must_be_strings | invalid_fields | unusable_name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "invalid_key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope | terms_not_accepted | brand_limited_key_cannot_create_brands",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "plan_brand_limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "body_too_large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/records": {
      "get": {
        "summary": "Records for up to 20 phone numbers",
        "x-scope": "records:read",
        "parameters": [
          {
            "name": "phone",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated; any common format."
          }
        ],
        "responses": {
          "200": {
            "description": "Matching intact records, at most 100 (truncated says if more exist)."
          },
          "400": {
            "description": "no_number | too_many_numbers | unreadable_number",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "invalid_key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/consents": {
      "post": {
        "summary": "Report one consent, as the named source this write key is",
        "x-scope": "records:write",
        "description": "The brand is the key’s own (a write key is limited to exactly one). Requires an Idempotency-Key header (8–200 printable characters): a byte-identical retry returns the original 201 with Idempotent-Replayed: true; a different body under the same key is 409. `timestamp` must be within 5 minutes of now; `capturedAt` must not be in the future or older than 24 hours (or the brand’s backdate window, if shorter). The words shown are `disclosureText`, verbatim. Each key has an owner-set daily cap (default 500 in any 24 hours, approximate under concurrency); past it, 429 daily_cap_reached. A TEST key runs every check and records nothing (200, recorded: false).",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "timestamp",
                  "phone",
                  "capturedAt",
                  "capturedAtPrecision",
                  "disclosureText"
                ],
                "properties": {
                  "timestamp": {
                    "type": "string",
                    "format": "date-time",
                    "description": "When this request was made."
                  },
                  "phone": {
                    "type": "string"
                  },
                  "capturedAt": {
                    "type": "string",
                    "format": "date-time",
                    "description": "When the person consented."
                  },
                  "capturedAtPrecision": {
                    "type": "string",
                    "enum": [
                      "exact",
                      "date_only",
                      "estimated"
                    ],
                    "description": "How precisely capturedAt is known."
                  },
                  "disclosureText": {
                    "type": "string",
                    "description": "The exact words your system displayed, as it reports them."
                  },
                  "email": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "firstName": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "lastName": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "postalCode": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "stateProvince": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "callerReference": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "callerSystem": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A test key: every check passed and nothing was recorded."
          },
          "201": {
            "description": "Recorded: { publicId, chainPosition }."
          },
          "400": {
            "description": "a field is missing or unusable, or the timestamp/capturedAt is outside its window",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "invalid_key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope | not_live_yet | brand_closed | terms_not_accepted | key_not_limited_to_one_brand — brand_closed is final: the brand was removed and records nothing more",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "idempotency_key_reused | no_active_disclosure_version",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited | daily_cap_reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "busy_retry | unavailable_retry — nothing was written; retry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/records/{publicId}": {
      "get": {
        "summary": "One record by its public identifier",
        "x-scope": "certificates:read",
        "parameters": [
          {
            "name": "publicId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The record",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "record": {
                      "$ref": "#/components/schemas/Record"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "invalid_key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "not_found — also for any record this key may not see",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  }
}