Fedex Logo
Developer Portal

Postal Code Validation API

簡介

FedEx 郵區編號驗證 API 能讓 FedEx 客戶驗證郵區編號,並取得服務承諾。它支援城市、郵區編號、國家/地區以及與寄件地-目的地相關的查詢和驗證。它會在回覆中提供經過驗證的郵區編號和位置詳情。

郵區編號驗證 API 詳情

郵區編號驗證會驗證國家/地區和城市的郵區編號,並在回覆中提供清晰的郵區編號。目前格式化的郵區編號,為處理託運或建立託運標籤的必要條件。

此 API 使用所提供的輸入資料,例如託運日期、郵區編號、國家/地區代碼和其他各種資料,從而核對州份和城市值之間的不相符情況。如果找到不相符的情況,且國家為美國或加拿大,便會設定城市和州份。例如:FDXE - FedEx Express®、FDXG - FedEx Ground® 和 FXSP - FedEx Ground® Economy (前稱 FedEx SmartPost®)。API 會驗證所輸入的內容,並提供位置詳細資訊和清晰的郵區編號。

FedEx 支援向適用郵區編號和不適用郵區編號的國家/地區提供服務。

適用郵區編號的國家/地區

寄至該等國家/地區的貨件應在空運提單和其他文件上列明郵區編號,以協助減少延誤及將效率提升至最高。建議 FedEx Express 客戶將有效的郵區編號加入至下列國家/地區居住之收件人的地址中。

有關適用郵區編號國家/地區的更多資訊,請參閱適用郵區編號國家/地區

不適用郵區編號的國家/地區

顧名思義,FedEx 支援的該等國家/地區不適用郵區編號,因此不強制要求在貨件中提供郵區編號。客戶寄送貨件至不設郵區編號的國家/地區時,只須提供州份代碼或城市名稱。如果因此發生驗證錯誤,請嘗試輸入 \"00000\" 取代郵區編號,以便讓地址生效。使用該錯誤郵區編號不會導致遞送問題,因為它根本就不存在。

以下是使用 FedEx 郵區編號驗證 API 的好處:

  • 減少託運延誤並提高效率。
  • 增加準時及完成派送的數量。
  • 提升都市地區的 FedEx 服務,提供靈活的截件時間和收件時間表。

郵區編號驗證 API 的運作方式

FedEx 郵區編號驗證 API 會使用下方的端點,來驗證城市、國家/地區和寄件地-目的地的郵區編號。以下部分說明了端點的關鍵輸入和回應:

驗證郵區編號

此請求用於根據輸入詳情傳回郵遞詳情、清晰的郵區編號和位置說明。與此請求相關的關鍵輸入資料如下:

  • carrierCode
  • countryCode
  • stateOrProvinceCode
  • postalCode
  • shipDate

此請求的成功結果為 locationdetails,而所提供的輸入內容則為 cleanedpostalcode。如果郵區編號不正確,請求便會失敗,例如:國家/地區代碼、州份/省份和郵區編號的組合不正確。

釐清常見謬誤

  • 由於地區調整和郵區編號乃完全分開的調整流程輸出,因此無法將兩者互相參照。
  • 並非世界上的所有地理位置均有郵區編號。

如需《地區專屬清單》的更多資訊,請參閱《地區專屬服務清單》。

業務規則

  • 數字、街道名稱等的組合有效的實體地址須有至少一行;地址中不允許有空白行。
  • 如果收件人所在國家為美國或加拿大,或者若 EEI 適用且國家為墨西哥 {MX},便須提供 2 個英文字母的州份或省份代碼。
  • 實體地點的說明資料可用作實體地址 (一個可供人前往的地方),或者用作 \"address parts\" 的容器,並應作為單位進行處理 (例如美國境內的州份和城市郵區編號組合)。
  • 郵區編號欄位存在與否及其格式如何,視乎國家/地區而定。

JSON API 系列

Postal Code Validation API (1.0.0)

Validate Postal

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.

header Parameters
x-customer-transaction-id
string
Example: 624deea6-b709-470c-8c39-4b5511281492

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.

content-type
required
string
Example: application/json

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.

x-locale
string
Example: en_US

This indicates the combination of language code and country code. Click here to see Locales

authorization
required
string
Example: Bearer XXX

This indicates the authorization token for the input request.

Request Body schema: application/json
One of
  • FullSchema-ValidatePostal
  • MinimumSamplePayload
carrierCode
required
string
Enum: "FDXE" "FDXG" "FXSP" "FDXC" "FXCC"

Specify the four letter code of a FedEx operating company that meets your requirements
Examples of FedEx Operating Companies are:

  • FDXE - FedEx Express
  • FDXG - FedEx Ground
  • FXSP - FedEx SmartPost
  • FXCC - FedEx Custom Critical.

countryCode
required
string

The two-letter code used to identify a country.
Example:US
Click here to see Country Codes

stateOrProvinceCode
required
string

This is the state or province code. Format and presence of this field will vary, depending on country.
Example: US
Click here to see State Or Province Code

postalCode
required
string

Identification code of a region (usally small) for easier and accurate mail/package delivery. The format and presence of this field may vary depending on the country.
Example: 75063-8659
Click here to see Postal aware countries

shipDate
required
string

Specify the date on which the package is to be shipped. The specified date should not be the current date or any date, 10 days after the current date. The date format must be YYYY-MM-DD.
Example: 2019-10-04

routingCode
string

Specify the routing code for the shipment. Routing code is the information that identifies the route the package or shipment may take.
Example: Memphis 38017 - HKA/NQA

checkForMismatch
boolean

This element checks for mismatch between State/Province Code and Postal Code.

  • When the checkForMismatch is set TRUE, for U.S. and Canada: The values in State/Province Code are checked with respect to Postal Code provided. If these entries are valid, the response provides respective State/Province Code and Postal Code. In case of mismatch of Postal Code and State/Province Code an error message is displayed.
  • When the checkForMismatch is set FALSE, for U.S. and Canada: The values in State/Province Code are not checked with respect to Postal Code provided. Instead the given data is reflected in the response.

For regions other than U.S and Canada regardless of the value of checkForMismatch the State/Province Code are checked with respect to the Postal Code and the response provides the respective State/Province Code and Postal Code.

Responses

200

Success

400

Bad Request

401

Unauthorized

403

Forbidden

404

Not Found

500

Failure

503

Service Unavailable

post /country/v1/postal/validate

Sandbox Server

https://apis-sandbox.fedex.com/country/v1/postal/validate

Production Server

https://apis.fedex.com/country/v1/postal/validate

Request samples

Content type
application/json
Example
Copy
Expand all Collapse all
{
  • "carrierCode": "FDXG",
  • "countryCode": "US",
  • "stateOrProvinceCode": "US",
  • "postalCode": "502267",
  • "shipDate": "2019-10-04",
  • "routingCode": "Memphis 38017 - HKA/NQA",
  • "checkForMismatch": true
}

Response samples

Content type
application/json
Copy
Expand all Collapse all
{
  • "transactionId": "624deea6-b709-470c-8c39-4b5511281492",
  • "customerTransactionId": "AnyCo_order123456789",
  • "output":
    {
    }
}
CLOSE

Response

Copy