{
"openapi": "3.0.0",
"info": {
"title": "Postal Code Validation API",
"version": "1.0.0"
},
"servers": [
{
"url": "",
"description": "Sandbox Server"
},
{
"url": "",
"description": "Production Server"
}
],
"paths": {
"/country/v1/postal/validate": {
"post": {
"summary": "Validate Postal",
"description": "Use this endpoint to validate postal codes and service commitments. Supports city, postal, country and origin-destination related lookups and validations.
Note: FedEx APIs do not support Cross-Origin Resource Sharing (CORS) mechanism.",
"operationId": "Validate Postal",
"requestBody": {
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/FullSchema-ValidatePostal"
}
]
}
}
}
},
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CountryCXSResponseVO"
}
}
}
},
"400": {
"description": "Bad Request",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponseVO"
},
"example": {
"transactionId": "35fa49ec-1e8a-4334-abc5-7e640ac807ac",
"customerTransactionId": "AnyCo_order123456789",
"errors": [
{
"code": "CITYNAME.POSTALCODE.REQUIRED",
"message": "City Name or Postal Code is required."
}
]
}
}
}
},
"401": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponseVO401"
},
"example": {
"transactionId": "624deea6-b709-470c-8c39-4b5511281492",
"errors": [
{
"code": "NOT.AUTHORIZED.ERROR",
"message": "Access token expired. Please modify your request and try again."
}
]
}
}
}
},
"403": {
"description": "Forbidden",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponseVO403"
},
"example": {
"transactionId": "624deea6-b709-470c-8c39-4b5511281492",
"errors": [
{
"code": "FORBIDDEN.ERROR",
"message": "We could not authorize your credentials. Please check your permissions and try again."
}
]
}
}
}
},
"404": {
"description": "Not Found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponseVO404"
},
"example": {
"transactionId": "624deea6-b709-470c-8c39-4b5511281492",
"errors": [
{
"code": "NOT.FOUND.ERROR",
"message": "The resource you requested is no longer available. Please modify your request and try again."
}
]
}
}
}
},
"500": {
"description": "Failure",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponseVO500"
},
"example": {
"transactionId": "624deea6-b709-470c-8c39-4b5511281492",
"customerTransactionId": "AnyCo_order123456789",
"errors": [
{
"code": "INTERNAL.SERVER.ERROR",
"message": "We encountered an unexpected error and are working to resolve the issue. We apologize for any inconvenience. Please check back at a later time."
}
]
}
}
}
},
"503": {
"description": "Service Unavailable",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponseVO503"
},
"example": {
"transactionId": "624deea6-b709-470c-8c39-4b5511281492",
"customerTransactionId": "AnyCo_order123456789",
"errors": [
{
"code": "SERVICE.UNAVAILABLE.ERROR",
"message": "The service is currently unavailable and we are working to resolve the issue. We apologize for any inconvenience. Please check back at a later time."
}
]
}
}
}
}
},
"parameters": [
{
"in": "header",
"name": "x-customer-transaction-id",
"description": "This element allows you to assign a unique identifier to your transaction. This element is also returned in the reply and helps you match the request to the reply.",
"required": false,
"schema": {
"type": "string",
"example": "624deea6-b709-470c-8c39-4b5511281492"
}
},
{
"in": "header",
"name": "content-type",
"description": "This is used to indicate the media type of the resource. The media type is a string sent along with the file indicating format of the file.",
"required": true,
"schema": {
"type": "string",
"example": "application/json"
}
},
{
"in": "header",
"name": "x-locale",
"description": "This indicates the combination of language code and country code. Click here to see Locales",
"required": false,
"schema": {
"type": "string",
"example": "en_US"
}
},
{
"in": "header",
"name": "authorization",
"description": "This indicates the authorization token for the input request.",
"required": true,
"schema": {
"type": "string",
"example": "Bearer XXX"
}
}
],
"x-code-samples": [
{
"lang": "C#",
"source": "var client = new RestClient(\"https://apis-sandbox.fedex.com/country/v1/postal/validate\");\nvar request = new RestRequest(Method.POST);\nrequest.AddHeader(\"Authorization\", \"Bearer \");\nrequest.AddHeader(\"X-locale\", \"en_US\");\nrequest.AddHeader(\"Content-Type\", \"application/json\");\n// 'input' refers to JSON Payload\nrequest.AddParameter(\"application/x-www-form-urlencoded\", input, ParameterType.RequestBody);\nIRestResponse response = client.Execute(request);\n\n\n\n\n"
},
{
"lang": "JAVA",
"source": "OkHttpClient client = new OkHttpClient();\n\nMediaType mediaType = MediaType.parse(\"application/json\");\n// 'input' refers to JSON Payload\nRequestBody body = RequestBody.create(mediaType, input);\nRequest request = new Request.Builder()\n .url(\"https://apis-sandbox.fedex.com/country/v1/postal/validate\")\n .post(body)\n .addHeader(\"Content-Type\", \"application/json\")\n .addHeader(\"X-locale\", \"en_US\")\n .addHeader(\"Authorization\", \"Bearer \")\n .build();\n \nResponse response = client.newCall(request).execute();"
},
{
"lang": "JAVASCRIPT",
"source": "// 'input' refers to JSON Payload\nvar data = JSON.stringify(input);\n \n var xhr = new XMLHttpRequest();\n xhr.withCredentials = true;\n \n xhr.addEventListener(\"readystatechange\", function () {\n if (this.readyState === 4) {\n console.log(this.responseText);\n }\n });\n \n xhr.open(\"POST\", \"https://apis-sandbox.fedex.com/country/v1/postal/validate\");\n xhr.setRequestHeader(\"Content-Type\", \"application/json\");\n xhr.setRequestHeader(\"X-locale\", \"en_US\");\n xhr.setRequestHeader(\"Authorization\", \"Bearer \");\n \n xhr.send(data);"
},
{
"lang": "PHP",
"source": "setUrl('https://apis-sandbox.fedex.com/country/v1/postal/validate');\n$request->setMethod(HTTP_METH_POST);\n\n$request->setHeaders(array(\n 'Authorization' => 'Bearer ',\n 'X-locale' => 'en_US',\n 'Content-Type' => 'application/json'\n));\n\n$request->setBody(input); // 'input' refers to JSON Payload\n\ntry {\n $response = $request->send();\n\n echo $response->getBody();\n} catch (HttpException $ex) {\n echo $ex;\n}"
},
{
"lang": "PYTHON",
"source": "import requests\n\nurl = \"https://apis-sandbox.fedex.com/country/v1/postal/validate\"\n\npayload = input # 'input' refers to JSON Payload\nheaders = {\n 'Content-Type': \"application/json\",\n 'X-locale': \"en_US\",\n 'Authorization': \"Bearer \"\n }\n\nresponse = requests.post(url, data=payload, headers=headers)\n\nprint(response.text)"
},
{
"lang": "RUST",
"source": "extern crate reqwest;\n\nuse std::io::Read;\n\nfn construct_headers() -> HeaderMap {\n let mut headers = HeaderMap::new();\n headers.insert(\"Content-Type\", \"application/json\");\n headers.insert(\"X-locale\", \"en_US\");\n headers.insert(\"Authorization\", \"Bearer \");\n headers\n}\n\nfn run() -> Result<()> {\n let client = reqwest::Client::new();\n let mut res = client.post(\"https://apis-sandbox.fedex.com/country/v1/postal/validate\")\n .body(input) // 'input' refers to JSON Payload\n .headers(construct_headers())\n .send()?;\n let mut body = String::new();\n res.read_to_string(&mut body)?;\n\n println!(\"Status: {}\", res.status());\n println!(\"Headers:\\n{:#?}\", res.headers());\n println!(\"Body:\\n{}\", body);\n\n Ok(())\n}"
},
{
"lang": "SWIFT",
"source": "import Foundation\n\nlet headers = [\n \"Content-Type\": \"application/json\",\n \"X-locale\": \"en_US\",\n \"Authorization\": \"Bearer \"\n]\nlet parameters = [\n input // 'input' refers to JSON Payload\n] as [String : Any]\n\nlet postData = JSONSerialization.data(withJSONObject: parameters, options: [])\n\nlet request = NSMutableURLRequest(url: NSURL(string: \"https://apis-sandbox.fedex.com/country/v1/postal/validate\")! as URL,\n cachePolicy: .useProtocolCachePolicy,\n timeoutInterval: 10.0)\nrequest.httpMethod = \"POST\"\nrequest.allHTTPHeaderFields = headers\nrequest.httpBody = postData as Data\n\nlet session = URLSession.shared\nlet dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in\n if (error != nil) {\n print(error)\n } else {\n let httpResponse = response as? HTTPURLResponse\n print(httpResponse)\n }\n})\n\ndataTask.resume()"
}
]
}
}
},
"components": {
"schemas": {
"FullSchema-ValidatePostal": {
"required": [
"carrierCode",
"countryCode",
"postalCode",
"shipDate",
"stateOrProvinceCode"
],
"type": "object",
"properties": {
"carrierCode": {
"type": "string",
"description": "Specify the four letter code of a FedEx operating company that meets your requirements
Examples of FedEx Operating Companies are: