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 - codefixup@gmail.com


  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 “codefixup@gmail.com”

  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).

        • Yes exactly , i also wants same.. when using india to india address,, fedexp apj not supported at all.

    • 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’

  11. I have used this code , but when i enter indian address . i have received following error;
    [Notifications] => stdClass Object
    [Severity] => ERROR
    [Source] => ship
    [Code] => 2449
    [Message] => Customs Clearance Detail is required
    [LocalizedMessage] => Customs Clearance Detail is required

    but when i use outside india .. its working ..
    so my concern is that , why i receiving that customclearance error in india address.

    • Hi Piyush,

      Fedex have different policies for each country. If custom clearance is required for India country than you should pass those parameters in API request. This given code belong to US country.


  12. Hello , Could you please send me code that is related to india.. ?

    • Hello , Could you please send me code that is related to india.. ? please send Label.php according to india shipping label format.

      • Well, currently i don’t have Fedex shipping code for India country basis. You should check Fedex api documentation to create an request for it.

  13. I have used your code but I am unable to generate label. So can you please let me know how can I generate the fedex label in png format?

    • Hi,

      Have you check label generation API call response. Should cross check it, it must parameter issue.

      For png label, change parameter value in LabelSpecification parameter. Follow Fedex official developer documentation for valid parameters and corresponding values.


  14. Can you please send me the full working code on my email.I am new in Apis integration .
    Thanks In Advance.

    • Hi Karan,

      I have explained here how to execute FedEX api call and print shipping label. You should follow fedex official documentation to create API request as per your need. If you need my service to create FedEX APIs call, inbox me on codefixup@gmail.com.


Leave a Reply

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