{
 "openapi": "3.1.0",
 "info": {
  "title": "Veriphone API",
  "version": "3",
  "summary": "Phone number validation and carrier lookup for 243 countries.",
  "description": "Validate phone numbers and get line type, carrier, region and formats in one REST call, for 243 countries. `mode=current` adds the carrier serving a ported number today. Bulk endpoints verify whole CSV files. You are charged only when `status` is `success`; errors are never charged. Free plan: 1,000 lookups a month — get a key at https://veriphone.io/signup.",
  "termsOfService": "https://veriphone.io/terms",
  "contact": {
   "name": "Veriphone",
   "url": "https://veriphone.io/contact"
  },
  "x-logo": {
   "url": "https://veriphone.io/img/logo.png"
  }
 },
 "externalDocs": {
  "description": "API reference",
  "url": "https://veriphone.io/docs/v3"
 },
 "servers": [
  {
   "url": "https://api.veriphone.io"
  }
 ],
 "security": [
  {
   "bearer": []
  },
  {
   "queryKey": []
  }
 ],
 "tags": [
  {
   "name": "Verification",
   "description": "Single-number validation and carrier lookup."
  },
  {
   "name": "Bulk",
   "description": "Verify a whole CSV file.",
   "externalDocs": {
    "url": "https://veriphone.io/docs/bulk"
   }
  },
  {
   "name": "Account",
   "description": "Credits and coverage."
  }
 ],
 "paths": {
  "/v3/verify": {
   "get": {
    "tags": [
     "Verification"
    ],
    "operationId": "verifyPhone",
    "summary": "Validate a phone number",
    "description": "Validates a phone number and returns its line type, carrier, region and formats. With `mode=current`, also the carrier serving the number now.",
    "parameters": [
     {
      "name": "phone",
      "in": "query",
      "required": true,
      "description": "The phone number. International format recommended, e.g. `+14169670000`.",
      "schema": {
       "type": "string"
      },
      "example": "+14169670000"
     },
     {
      "name": "mode",
      "in": "query",
      "required": false,
      "description": "`static` (default, 1 credit) validates the number and reports its original carrier and line type from national numbering-plan data. `current` (10 credits) adds the carrier and line type serving the number today, ported or not; if it cannot be resolved you get the full static result and pay 1 credit.",
      "schema": {
       "type": "string",
       "enum": [
        "static",
        "current"
       ],
       "default": "static"
      }
     },
     {
      "name": "default_country",
      "in": "query",
      "required": false,
      "description": "ISO 3166-1 alpha-2 country code used when the number has no international prefix (e.g. `US`). Without it the country is inferred from the caller's IP.",
      "schema": {
       "type": "string",
       "pattern": "^[A-Za-z]{2}$"
      }
     },
     {
      "name": "record",
      "in": "query",
      "required": false,
      "description": "`true` to save the result to your verification history.",
      "schema": {
       "type": "boolean"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Verification result. `status: success` is charged; `phone_valid` carries the verdict.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Verification"
        },
        "example": {
         "status": "success",
         "phone": "+14169670000",
         "phone_valid": true,
         "phone_type": "fixed_line",
         "phone_region": "Toronto, ON",
         "country": "Canada",
         "country_code": "CA",
         "country_prefix": "1",
         "international_number": "+1 416-967-0000",
         "local_number": "(416) 967-0000",
         "e164": "+14169670000",
         "carrier": "Bell",
         "mode": "static",
         "timezone": [
          "America/Toronto"
         ],
         "geographical": true
        }
       }
      }
     },
     "400": {
      "description": "Invalid or missing input: a missing `phone` or API key, or an unsupported `mode`.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Invalid API key (on this endpoint a missing key returns 400).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "402": {
      "description": "Insufficient credits.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "Account inactive or access denied.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "500": {
      "description": "Server error.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/v3/credits": {
   "get": {
    "tags": [
     "Account"
    ],
    "operationId": "getCredits",
    "summary": "Credit balance and usage",
    "responses": {
     "200": {
      "description": "Balance and usage by lookup mode.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Credits"
        }
       }
      }
     },
     "401": {
      "description": "Missing or invalid API key.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/v3/coverage/current": {
   "get": {
    "tags": [
     "Account"
    ],
    "operationId": "getCurrentCoverage",
    "summary": "Countries covered by current-carrier lookups",
    "description": "Public, no API key needed.",
    "security": [],
    "responses": {
     "200": {
      "description": "Coverage list.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "countries": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "iso": {
              "type": "string"
             },
             "covered": {
              "type": "boolean"
             }
            }
           }
          },
          "updatedAt": {
           "type": "string",
           "format": "date-time"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/v3/file/upload": {
   "post": {
    "tags": [
     "Bulk"
    ],
    "operationId": "uploadFile",
    "summary": "Upload a CSV file",
    "requestBody": {
     "required": true,
     "content": {
      "multipart/form-data": {
       "schema": {
        "type": "object",
        "required": [
         "file",
         "column",
         "firstrow"
        ],
        "properties": {
         "file": {
          "type": "string",
          "format": "binary",
          "description": "CSV file. Max 100 MB, max 1 million rows."
         },
         "column": {
          "type": "integer",
          "description": "Zero-based index of the column holding phone numbers."
         },
         "firstrow": {
          "type": "integer",
          "description": "Zero-based index of the first data row (skip headers)."
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Upload accepted.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "result": {
           "type": "string"
          },
          "id": {
           "type": "string"
          },
          "column": {
           "type": "integer"
          },
          "firstrow": {
           "type": "integer"
          },
          "lastrow": {
           "type": "integer"
          },
          "record1": {
           "type": "string"
          },
          "record2": {
           "type": "string"
          }
         }
        }
       }
      }
     },
     "400": {
      "description": "Not a .csv, too large, too many rows, or missing column/firstrow.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Missing or invalid API key.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/v3/file/verify": {
   "post": {
    "tags": [
     "Bulk"
    ],
    "operationId": "verifyFile",
    "summary": "Start verifying an uploaded file",
    "description": "Starts a background job. Poll /v3/file/status, then download the results.",
    "parameters": [
     {
      "name": "id",
      "in": "query",
      "required": true,
      "description": "Upload ID returned by /v3/file/upload.",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "default_country",
      "in": "query",
      "required": false,
      "description": "ISO 3166-1 alpha-2 country code used when the number has no international prefix (e.g. `US`). Without it the country is inferred from the caller's IP.",
      "schema": {
       "type": "string",
       "pattern": "^[A-Za-z]{2}$"
      }
     },
     {
      "name": "mode",
      "in": "query",
      "required": false,
      "description": "`static` (default, 1 credit) validates the number and reports its original carrier and line type from national numbering-plan data. `current` (10 credits) adds the carrier and line type serving the number today, ported or not; if it cannot be resolved you get the full static result and pay 1 credit.",
      "schema": {
       "type": "string",
       "enum": [
        "static",
        "current"
       ],
       "default": "static"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Job started.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "status": {
           "type": "string"
          },
          "id": {
           "type": "string"
          }
         }
        }
       }
      }
     },
     "402": {
      "description": "Insufficient credits; the body carries `credits_required` and `credits_available`.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "File not ready, not yours, or account inactive.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "File not found.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/v3/file/list": {
   "get": {
    "tags": [
     "Bulk"
    ],
    "operationId": "listFiles",
    "summary": "List uploads, newest first",
    "responses": {
     "401": {
      "description": "Missing or invalid API key.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "200": {
      "description": "Uploads.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "status": {
           "type": "string"
          },
          "uploads": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "id": {
              "type": "string"
             },
             "name": {
              "type": "string"
             },
             "status": {
              "type": "string",
              "enum": [
               "new",
               "ready",
               "verifying",
               "completed",
               "deleted"
              ]
             },
             "filesize": {
              "type": "integer"
             },
             "created": {
              "type": "string",
              "format": "date-time"
             },
             "firstrow": {
              "type": "integer"
             },
             "lastrow": {
              "type": "integer"
             },
             "column": {
              "type": "integer"
             },
             "position": {
              "type": "integer",
              "description": "Current processing row."
             },
             "stage": {
              "type": "string"
             },
             "speed": {
              "type": "number",
              "description": "Rows per second."
             },
             "billable": {
              "type": "integer",
              "description": "Rows that counted against credits."
             },
             "syntaxerr": {
              "type": "integer",
              "description": "Rows with phone number syntax errors (not billed)."
             },
             "valid": {
              "type": "integer"
             },
             "invalid": {
              "type": "integer"
             },
             "record1": {
              "type": "string"
             },
             "record2": {
              "type": "string"
             }
            }
           }
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/v3/file/get": {
   "get": {
    "tags": [
     "Bulk"
    ],
    "operationId": "getFile",
    "summary": "One upload's details",
    "parameters": [
     {
      "name": "id",
      "in": "query",
      "required": true,
      "description": "Upload ID returned by /v3/file/upload.",
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "401": {
      "description": "Missing or invalid API key.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "200": {
      "description": "The upload, or an empty object if it does not exist or is not yours.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "id": {
           "type": "string"
          },
          "name": {
           "type": "string"
          },
          "status": {
           "type": "string",
           "enum": [
            "new",
            "ready",
            "verifying",
            "completed",
            "deleted"
           ]
          },
          "filesize": {
           "type": "integer"
          },
          "created": {
           "type": "string",
           "format": "date-time"
          },
          "firstrow": {
           "type": "integer"
          },
          "lastrow": {
           "type": "integer"
          },
          "column": {
           "type": "integer"
          },
          "position": {
           "type": "integer",
           "description": "Current processing row."
          },
          "stage": {
           "type": "string"
          },
          "speed": {
           "type": "number",
           "description": "Rows per second."
          },
          "billable": {
           "type": "integer",
           "description": "Rows that counted against credits."
          },
          "syntaxerr": {
           "type": "integer",
           "description": "Rows with phone number syntax errors (not billed)."
          },
          "valid": {
           "type": "integer"
          },
          "invalid": {
           "type": "integer"
          },
          "record1": {
           "type": "string"
          },
          "record2": {
           "type": "string"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/v3/file/status": {
   "get": {
    "tags": [
     "Bulk"
    ],
    "operationId": "getFileStatus",
    "summary": "Poll a bulk job",
    "parameters": [
     {
      "name": "id",
      "in": "query",
      "required": true,
      "description": "Upload ID returned by /v3/file/upload.",
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "401": {
      "description": "Missing or invalid API key.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "200": {
      "description": "Job status.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "id": {
           "type": "string"
          },
          "status": {
           "type": "string"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/v3/file/download": {
   "get": {
    "tags": [
     "Bulk"
    ],
    "operationId": "downloadFile",
    "summary": "Download the results CSV",
    "description": "Returns the verified file: every original column plus phone_valid, e164, local_number, type, country, region and carrier (and ported, current_carrier, current_line_type, current_lookup for mode=current). Returns the original file if not yet verified.",
    "parameters": [
     {
      "name": "id",
      "in": "query",
      "required": true,
      "description": "Upload ID returned by /v3/file/upload.",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "as",
      "in": "query",
      "required": false,
      "description": "File name for Content-Disposition.",
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "CSV file.",
      "content": {
       "application/octet-stream": {
        "schema": {
         "type": "string",
         "format": "binary"
        }
       }
      }
     },
     "404": {
      "description": "File not found.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/v3/file/delete": {
   "post": {
    "tags": [
     "Bulk"
    ],
    "operationId": "deleteFile",
    "summary": "Delete an upload and its results",
    "parameters": [
     {
      "name": "id",
      "in": "query",
      "required": true,
      "description": "Upload ID returned by /v3/file/upload.",
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Deleted.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "status": {
           "type": "string"
          }
         }
        }
       }
      }
     },
     "403": {
      "description": "Not your file.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "File not found.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  }
 },
 "components": {
  "securitySchemes": {
   "bearer": {
    "type": "http",
    "scheme": "bearer",
    "description": "Your API key as a Bearer token (recommended)."
   },
   "queryKey": {
    "type": "apiKey",
    "in": "query",
    "name": "key",
    "description": "Your API key as the `key` query parameter."
   }
  },
  "schemas": {
   "Error": {
    "type": "object",
    "properties": {
     "status": {
      "type": "string",
      "const": "error"
     },
     "code": {
      "type": "integer"
     },
     "type": {
      "type": "string"
     },
     "message": {
      "type": "string"
     }
    }
   },
   "Credits": {
    "type": "object",
    "properties": {
     "email": {
      "type": "string"
     },
     "counter": {
      "type": "integer"
     },
     "active": {
      "type": "boolean"
     },
     "payg": {
      "type": "integer"
     },
     "limit": {
      "type": "integer"
     },
     "plan": {
      "type": "string"
     },
     "renew": {
      "type": "integer"
     },
     "usage": {
      "type": "object",
      "additionalProperties": {
       "type": "object",
       "properties": {
        "count": {
         "type": "integer"
        },
        "credits": {
         "type": "integer"
        }
       }
      }
     }
    }
   },
   "Verification": {
    "type": "object",
    "required": [
     "status"
    ],
    "properties": {
     "status": {
      "type": "string",
      "enum": [
       "success",
       "error"
      ],
      "description": "`success`: a verification happened (the only charged status). `error`: no verification (input is not a phone number, or an API error); never charged."
     },
     "phone": {
      "type": "string",
      "description": "E.164 when valid, otherwise your input."
     },
     "phone_valid": {
      "type": "boolean",
      "description": "Whether the number is in a range carriers can assign. Says nothing about whether the line is in use."
     },
     "reason": {
      "type": "string",
      "enum": [
       "too_short",
       "too_long",
       "invalid_length",
       "invalid_country_code",
       "unrecognized_range",
       "not_a_number"
      ],
      "description": "Only when not valid."
     },
     "phone_type": {
      "type": "string",
      "description": "mobile, fixed_line, voip, toll_free, fixed_line_or_mobile, short_code, emergency, …"
     },
     "shortcode_cost": {
      "type": "string",
      "enum": [
       "toll_free",
       "standard_rate",
       "premium_rate",
       "unknown"
      ]
     },
     "carrier": {
      "type": "string",
      "description": "Carrier of the number's range."
     },
     "phone_region": {
      "type": "string"
     },
     "country": {
      "type": "string"
     },
     "country_code": {
      "type": "string"
     },
     "country_prefix": {
      "type": "string"
     },
     "international_number": {
      "type": "string"
     },
     "local_number": {
      "type": "string"
     },
     "e164": {
      "type": "string"
     },
     "timezone": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "geographical": {
      "type": "boolean"
     },
     "mode": {
      "type": "string",
      "enum": [
       "static",
       "current"
      ]
     },
     "original_carrier": {
      "type": "string",
      "description": "mode=current only."
     },
     "original_line_type": {
      "type": "string",
      "description": "mode=current only."
     },
     "current_carrier": {
      "type": [
       "string",
       "null"
      ],
      "description": "mode=current only: the carrier serving the number now."
     },
     "current_line_type": {
      "type": [
       "string",
       "null"
      ],
      "description": "mode=current only."
     },
     "current_mccmnc": {
      "type": [
       "string",
       "null"
      ]
     },
     "original_mccmnc": {
      "type": [
       "string",
       "null"
      ]
     },
     "ported": {
      "type": [
       "boolean",
       "null"
      ],
      "description": "mode=current only: true when the number has left its original allocation."
     },
     "current_lookup": {
      "type": "string",
      "description": "`unavailable` when the current carrier could not be resolved (charged as static)."
     },
     "carrier_data_source": {
      "type": "string"
     }
    }
   }
  }
 }
}