How to Print Fedex Shipping label via API call in PHP

In this post i will explain you how we use fedex api to create a shipping label in PHP. First you have to send the shipment request to confirm shipping than print shipping label.

Use you fedex test developer account for label generation. You can not use direct production account access for label generation. Because fedex did not allow this and give an authentication error. When you print shipping label using test account than pass label format to fedex for evaluation. Fedex will check your label format and provided information and than approve it for production account.

You need to certified fedex account for use production access for shipping and label generation.

Steps to print fedex shipping label via API in PHP:

Step 1: We are using soap client request for fedex label. For this you need to include “ShipService_v19.wsdl” file.

Step 2: Create a Label.php file using below code. Which call the fedex test api request url.

After using this file label image will show on screen. You can also create custom fedex shipping label as per your requirement. Follow this Fedex Developer Guide Reference.

Also Read This:

How to Create Fedex Multiple Package Shipment Label using API Call in PHP
How to Add New Product in Bigcommerce via API V2
How to Insert New Lead Data in Zoho CRM Through API
How to Install Magento Security Patch via Putty

We can also use simple xml request parameter for creating fedex api label in php using curl method. Although above method is quite easy to implement on website.


I am professional web developer and blogger. Use this blog to share own api and other web development experience with you. I do accept paid work. Write to me to start working on your dream project - [email protected]


  1. Appreciate the code, but generated pdf files were of zero kb, any idea?

    • Hello Kausik,
      Which service type you use for generate shipping label ? Can you share your soap request code ?

  2. Hi Harish,

    I simply uploaded ShipService_v17.wsdl and label.php with your code under a folder and tried to execute the php file. Do I need to do any thing else? If you share your email id, I can share test key and other details.

    • Have you change shiptimestamp with next shipping date in request ? Still facing issue, mail me info on this id “[email protected]

  3. Hi again,
    in your code what are parent and user credential? IN FEDX php code also I don’t see any such reference. Can you please explain?

    $request[‘WebAuthenticationDetail’] = array(
    ‘ParentCredential’ => array(
    ‘Key’ => ‘EPLkBjBoWJL4gWDz’,
    ‘Password’ => ‘6RrOFaG3V9hP2tRwll58Tunb0’
    ‘UserCredential’ => array(
    ‘Key’ => ‘EPLkBjBoWJL4gWDz’,
    ‘Password’ => ‘6RrOFaG3V9hP2tRwll58Tunb0’

  4. Dear Harish,

    I mailed you the file with code in the morning, did you get chance to check it?


    • Hi Kausik,
      I tried your code with my fedex test account access. Its work fine. You should change Shipper Address and Recipient address by own developer test address.

      When you create fedex development key, they will mail you test address for using fedex services.

    • Hello, i just email you working code. Just edit shipper and recipient address and its work fine.

  5. sir i need some help to integrate fedex api to my website
    ,i want to check availiability of service of fedex depend on postal code

    • Hello sandeep,

      I think for this you need to run Fedex Postal Code Inquiry api. Which give result shipping available on particular post code or not.

  6. I used same Test key & password in credentials
    but I am getting this error

    Severity: ERROR
    Source: prof
    Code: 1000
    Message: Authentication Failed

    • Hi Tut,

      You must use Test Development Access, which you got at the time of registration in fedex account.

      Also for label request change shipper and recipient address as per your fedex account.

  7. Hello Harish ,
    I did all chages suggested by you still it shows authentication failed error.Please check my attached file on your mail and suggest me appropriate changes.

  8. Which account number is used in script?
    That is define in Test password mail.Or that are defined in shipper and recipient address.

    • Hi Rohit,

      Authentication error comes when you trying to create fedex label using production account access without evaluation process. Are you using right developer access in it ?

  9. Hi Harish,
    Hello Harish,
    I just mailed you the new file with script , did you get chance to check it?

  10. Hi Harish,

    I am doing integration of fedex api in php, I use rate available api to get list of services. But can you help to for next step. i think we have to place shipping order to get tracking code.

    So, it will be helpful if you provide some information on it.

    • Hi sam,

      You have to write Fedex Shipping label code to get tracking code. Just place a test order with fedex service type to create shipping label. I hope this post will help to do this.


      • Thanks for your prompt reply, as in create shipment there are different folders and each have shipment file init. so which one i use as i want to create shipment for india. (like: form india to india).

    • Hi Rohit,

      If you are using FEDEX_GROUND service type than COD parameter is required in label request. For print Non COD Fedex label for other service, just remove these request parameter from label request code.

      ‘SpecialServicesRequested’ => array(
      ‘SpecialServiceTypes’ => ‘COD’,
      ‘CodDetail’ => array(
      ‘CodCollectionAmount’ => array(
      ‘Currency’ => ‘USD’,
      ‘Amount’ => ‘10.0’
      ‘CollectionType’ => ‘ANY’

Leave a Reply

Your email address will not be published. Required fields are marked *