{
  "openapi": "3.1.0",
  "info": {
    "title": "Barcode API v2",
    "version": "2.0.0",
    "description": "Same-origin server gateway for a configured v2 provider. Each local API key uses the provider account assigned to its owner."
  },
  "servers": [
    {
      "url": "/api/v2"
    }
  ],
  "security": [
    {
      "apiKey": []
    }
  ],
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  },
  "paths": {
    "/balance": {
      "get": {
        "summary": "Read account credits",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "credits": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "503": {
            "description": "Provider access is not configured for this account."
          }
        }
      }
    },
    "/jurisdictions": {
      "get": {
        "summary": "List jurisdictions",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "iin": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "503": {
            "description": "Provider access is not configured for this account."
          }
        },
        "parameters": [
          {
            "name": "country",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "USA",
                "CAN"
              ]
            },
            "in": "query"
          }
        ]
      }
    },
    "/revisions": {
      "get": {
        "summary": "List jurisdiction revisions",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "object",
                    "properties": {
                      "revision": {
                        "type": "string"
                      },
                      "aamva_version": {
                        "type": "string"
                      },
                      "jurisdiction_version": {
                        "type": "string"
                      },
                      "start": {
                        "type": "string"
                      },
                      "end": {
                        "type": [
                          "string",
                          "null"
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "503": {
            "description": "Provider access is not configured for this account."
          }
        },
        "parameters": [
          {
            "name": "jurisdiction",
            "required": true,
            "schema": {
              "type": "string"
            },
            "in": "query"
          }
        ]
      }
    },
    "/elements": {
      "get": {
        "summary": "Read field definitions",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "object",
                      "properties": {
                        "element": {
                          "type": "string"
                        },
                        "type": {
                          "type": "string"
                        },
                        "default": {},
                        "options": {
                          "oneOf": [
                            {
                              "type": "object",
                              "additionalProperties": {
                                "type": "string"
                              }
                            },
                            {
                              "type": "array"
                            }
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "503": {
            "description": "Provider access is not configured for this account."
          }
        },
        "parameters": [
          {
            "name": "jurisdiction",
            "required": true,
            "schema": {
              "type": "string"
            },
            "in": "query"
          },
          {
            "name": "revision",
            "required": false,
            "schema": {
              "type": "string"
            },
            "in": "query"
          }
        ]
      }
    },
    "/barcode": {
      "post": {
        "summary": "Generate a barcode",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/jpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/bmp": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/svg+xml": {
                "schema": {
                  "type": "string"
                }
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            },
            "headers": {
              "X-Barcode-ID": {
                "description": "Present when saved",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "415": {
            "description": "Unsupported Accept media type"
          },
          "503": {
            "description": "Provider access is not configured for this account."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "jurisdiction": {
                    "type": "string"
                  },
                  "revision": {
                    "type": "string"
                  },
                  "document": {
                    "type": "string",
                    "enum": [
                      "DL",
                      "ID",
                      "CDL"
                    ],
                    "default": "DL"
                  },
                  "save": {
                    "type": "boolean",
                    "default": true
                  },
                  "data": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "jurisdiction",
                  "data"
                ]
              },
              "encoding": {
                "data": {
                  "style": "deepObject",
                  "explode": true
                }
              }
            }
          }
        }
      }
    },
    "/export": {
      "get": {
        "summary": "Export a saved PDF417 barcode",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/jpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/bmp": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/svg+xml": {
                "schema": {
                  "type": "string"
                }
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "415": {
            "description": "Unsupported Accept media type"
          },
          "503": {
            "description": "Provider access is not configured for this account."
          }
        },
        "parameters": [
          {
            "name": "barcode_id",
            "required": true,
            "schema": {
              "type": "string"
            },
            "in": "query"
          },
          {
            "name": "ecl",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 8
            },
            "in": "query"
          },
          {
            "name": "ratio",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 2,
              "maximum": 7
            },
            "in": "query"
          },
          {
            "name": "cols",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 30
            },
            "in": "query"
          },
          {
            "name": "rows",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 3,
              "maximum": 90
            },
            "in": "query"
          },
          {
            "name": "bwr",
            "required": false,
            "schema": {
              "type": "number"
            },
            "in": "query"
          }
        ]
      }
    },
    "/linear": {
      "get": {
        "summary": "Export a companion linear barcode",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/jpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/svg+xml": {
                "schema": {
                  "type": "string"
                }
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "application/json": {
                "schema": {
                  "type": "object"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "415": {
            "description": "Unsupported Accept media type"
          },
          "503": {
            "description": "Provider access is not configured for this account."
          }
        },
        "parameters": [
          {
            "name": "barcode_id",
            "required": true,
            "schema": {
              "type": "string"
            },
            "in": "query"
          }
        ]
      }
    },
    "/validate": {
      "get": {
        "summary": "Read provider validation results",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "fidscan": {
                      "type": [
                        "object",
                        "null"
                      ],
                      "properties": {
                        "valid": {
                          "type": "boolean"
                        },
                        "confidence": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 100
                        },
                        "errors": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "veriscan": {
                      "type": [
                        "object",
                        "null"
                      ],
                      "properties": {
                        "valid": {
                          "type": "boolean"
                        },
                        "confidence": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 100
                        },
                        "errors": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "checkpoint": {
                      "type": [
                        "object",
                        "null"
                      ],
                      "properties": {
                        "valid": {
                          "type": "boolean"
                        },
                        "confidence": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 100
                        },
                        "errors": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "intellicheck": {
                      "type": [
                        "object",
                        "null"
                      ],
                      "properties": {
                        "valid": {
                          "type": "boolean"
                        },
                        "confidence": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 100
                        },
                        "errors": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "503": {
            "description": "Provider access is not configured for this account."
          }
        },
        "parameters": [
          {
            "name": "barcode_id",
            "required": true,
            "schema": {
              "type": "string"
            },
            "in": "query"
          }
        ],
        "description": "First validation costs one credit. Repeat requests reuse results without a second charge. Unavailable providers return null."
      }
    }
  }
}
