PHPackages                             smart-dato/fedex-rest-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. smart-dato/fedex-rest-sdk

ActiveLibrary

smart-dato/fedex-rest-sdk
=========================

FedEx REST SDK

0.0.1(2mo ago)00[1 PRs](https://github.com/smart-dato/fedex-rest-sdk/pulls)MITPHPPHP ^8.4CI passing

Since Mar 10Pushed 1mo agoCompare

[ Source](https://github.com/smart-dato/fedex-rest-sdk)[ Packagist](https://packagist.org/packages/smart-dato/fedex-rest-sdk)[ Docs](https://github.com/smart-dato/fedex-rest-sdk)[ GitHub Sponsors](https://github.com/SmartDato)[ RSS](/packages/smart-dato-fedex-rest-sdk/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (15)Versions (3)Used By (0)

FedEx REST SDK
==============

[](#fedex-rest-sdk)

[![Latest Version on Packagist](https://camo.githubusercontent.com/efc0755758545c2e9f15a05fde4d3355cd6b1441b82aad43950efa5d2119fb23/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736d6172742d6461746f2f66656465782d726573742d73646b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/smart-dato/fedex-rest-sdk)[![GitHub Tests Action Status](https://camo.githubusercontent.com/6cc9e3de0d3bf3b6ebc899d2abf001f701953558f1cfbd5ab9fea1439aaae976/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f736d6172742d6461746f2f66656465782d726573742d73646b2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/smart-dato/fedex-rest-sdk/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/9d8f7a3026d42d57c5ea1dda137eb13de6110b31dd51ba07420be2cef4da69fc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f736d6172742d6461746f2f66656465782d726573742d73646b2f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/smart-dato/fedex-rest-sdk/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/7f62bd86c7cc63bf18e717317ce770a6e726e80d645d8e9711e36d6e8484c5de/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736d6172742d6461746f2f66656465782d726573742d73646b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/smart-dato/fedex-rest-sdk)

Laravel package for integrating with the FedEx REST APIs. Supports shipment creation, cancellation, validation, tag management, and trade document uploads. Built on [Saloon 3.x](https://docs.saloon.dev) for HTTP and [Spatie Laravel Data 4.x](https://spatie.be/docs/laravel-data) for DTOs.

Requirements
------------

[](#requirements)

- PHP 8.4+
- Laravel 11 or 12

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require smart-dato/fedex-rest-sdk
```

Publish the config file:

```
php artisan vendor:publish --tag="fedex-rest-sdk-config"
```

Configuration
-------------

[](#configuration)

Add the following environment variables to your `.env` file:

```
FEDEX_CLIENT_ID=your-client-id
FEDEX_CLIENT_SECRET=your-client-secret
FEDEX_ACCOUNT_NUMBER=your-account-number
```

The published config file (`config/fedex-rest-sdk.php`) contains all available options:

```
return [
    'client_id' => env('FEDEX_CLIENT_ID'),
    'client_secret' => env('FEDEX_CLIENT_SECRET'),
    'account_number' => env('FEDEX_ACCOUNT_NUMBER'),

    'grant_type' => env('FEDEX_GRANT_TYPE', 'client_credentials'),
    'child_key' => env('FEDEX_CHILD_KEY'),
    'child_secret' => env('FEDEX_CHILD_SECRET'),

    'base_url' => env('FEDEX_BASE_URL', 'https://apis.fedex.com'),
    'document_base_url' => env('FEDEX_DOCUMENT_BASE_URL', 'https://documentapi.prod.fedex.com'),

    'verify_ssl' => env('FEDEX_VERIFY_SSL', true),
];
```

For the **sandbox** environment, override the URLs:

```
FEDEX_BASE_URL=https://apis-sandbox.fedex.com
FEDEX_DOCUMENT_BASE_URL=https://documentapitest.prod.fedex.com/sandbox
```

### Authentication Grant Types

[](#authentication-grant-types)

The SDK supports three FedEx authentication modes:

- `client_credentials` — Standard B2B (default)
- `csp_credentials` — Compatible/Integrator customers with child accounts
- `client_pc_credentials` — Proprietary Parent-Child customers

For CSP or Parent-Child authentication, also set:

```
FEDEX_GRANT_TYPE=csp_credentials
FEDEX_CHILD_KEY=your-child-key
FEDEX_CHILD_SECRET=your-child-secret
```

Usage
-----

[](#usage)

Resolve the SDK from the container (or use the `FedEx` facade):

```
use SmartDato\FedEx\FedEx;

$fedex = app(FedEx::class);
```

### Create a Shipment

[](#create-a-shipment)

```
use SmartDato\FedEx\Data\Ship\CreateShipmentData;

$request = CreateShipmentData::from([
    'accountNumber' => ['value' => '123456789'],
    'labelResponseOptions' => 'URL_ONLY',
    'requestedShipment' => [
        'shipper' => [
            'address' => [
                'streetLines' => ['123 Ship Street'],
                'city' => 'Memphis',
                'stateOrProvinceCode' => 'TN',
                'postalCode' => '38116',
                'countryCode' => 'US',
            ],
            'contact' => [
                'personName' => 'John Shipper',
                'phoneNumber' => '1234567890',
                'companyName' => 'Shipper Co',
            ],
        ],
        'recipients' => [
            [
                'address' => [
                    'streetLines' => ['456 Recipient Ave'],
                    'city' => 'Los Angeles',
                    'stateOrProvinceCode' => 'CA',
                    'postalCode' => '90001',
                    'countryCode' => 'US',
                ],
                'contact' => [
                    'personName' => 'Jane Recipient',
                    'phoneNumber' => '0987654321',
                    'companyName' => 'Recipient Inc',
                ],
            ],
        ],
        'pickupType' => 'DROPOFF_AT_FEDEX_LOCATION',
        'serviceType' => 'STANDARD_OVERNIGHT',
        'packagingType' => 'YOUR_PACKAGING',
        'totalWeight' => 10.0,
        'shippingChargesPayment' => [
            'paymentType' => 'SENDER',
        ],
        'labelSpecification' => [
            'imageType' => 'PDF',
            'labelStockType' => 'PAPER_4X6',
        ],
        'requestedPackageLineItems' => [
            [
                'weight' => [
                    'units' => 'LB',
                    'value' => 10.0,
                ],
            ],
        ],
    ],
]);

$response = $fedex->ship()->createShipment($request);

$response->transactionId;
$response->output->transactionShipments[0]->masterTrackingNumber;
$response->output->transactionShipments[0]->pieceResponses[0]->trackingNumber;
```

### Validate a Shipment

[](#validate-a-shipment)

```
use SmartDato\FedEx\Data\Ship\ValidateShipmentData;

$request = ValidateShipmentData::from([
    'accountNumber' => ['value' => '123456789'],
    'requestedShipment' => [
        // Same structure as create shipment
    ],
]);

$response = $fedex->ship()->validateShipment($request);

foreach ($response->output->alerts as $alert) {
    $alert->code;       // "SHIPMENT.VALIDATION.SUCCESS"
    $alert->alertType;  // "NOTE"
    $alert->message;
}
```

### Cancel a Shipment

[](#cancel-a-shipment)

```
use SmartDato\FedEx\Data\Ship\CancelShipmentData;

$request = CancelShipmentData::from([
    'accountNumber' => ['value' => '123456789'],
    'trackingNumber' => '794644790138',
]);

$response = $fedex->ship()->cancelShipment($request);

$response->output->cancelledShipment;  // true
```

### Create and Cancel Tags

[](#create-and-cancel-tags)

```
use SmartDato\FedEx\Data\Ship\CreateTagData;
use SmartDato\FedEx\Data\Ship\CancelTagData;

// Create a tag
$response = $fedex->ship()->createTag(CreateTagData::from([
    'accountNumber' => ['value' => '123456789'],
    'requestedShipment' => [/* ... */],
]));

$response->output->masterTrackingNumber;
$response->output->completedTagDetail->confirmationNumber;

// Cancel a tag
$fedex->ship()->cancelTag(CancelTagData::from([
    'accountNumber' => ['value' => '123456789'],
    'serviceType' => 'PRIORITY_OVERNIGHT',
    'completedTagDetail' => [
        'confirmationNumber' => 'CONF123',
    ],
]), shipmentId: 'SHIP123');
```

### Retrieve Async Shipment Results

[](#retrieve-async-shipment-results)

For shipments with 40+ packages processed asynchronously:

```
use SmartDato\FedEx\Data\Ship\AsyncResultsData;

$response = $fedex->ship()->retrieveAsyncResults(AsyncResultsData::from([
    'accountNumber' => ['value' => '123456789'],
    'jobId' => '624deea6-b709-470c-8c39-4b5511281492',
]));
```

### Upload Trade Documents

[](#upload-trade-documents)

```
use SmartDato\FedEx\Data\Document\UploadDocumentData;

$data = UploadDocumentData::from([
    'workflowName' => 'ETDPreshipment',
    'name' => 'commercial_invoice.pdf',
    'contentType' => 'application/pdf',
    'meta' => [
        'shipDocumentType' => 'COMMERCIAL_INVOICE',
        'originCountryCode' => 'US',
        'destinationCountryCode' => 'CA',
    ],
]);

$response = $fedex->documents()->uploadDocument($data, '/path/to/commercial_invoice.pdf');

$response->output->meta->docId;        // Use this in your shipment request
$response->output->meta->documentType;  // "CI"
```

### Upload Multiple Documents

[](#upload-multiple-documents)

```
use SmartDato\FedEx\Data\Document\MultiUploadDocumentData;

$data = MultiUploadDocumentData::from([
    'workflowName' => 'ETDPreshipment',
    'carrierCode' => 'FDXE',
    'originCountryCode' => 'US',
    'destinationCountryCode' => 'CA',
    'metaData' => [
        [
            'fileName' => 'invoice.pdf',
            'contentType' => 'application/pdf',
            'shipDocumentType' => 'COMMERCIAL_INVOICE',
        ],
        [
            'fileName' => 'certificate.pdf',
            'contentType' => 'application/pdf',
            'shipDocumentType' => 'CERTIFICATE_OF_ORIGIN',
        ],
    ],
]);

$response = $fedex->documents()->multiUploadDocuments($data, [
    '/path/to/invoice.pdf',
    '/path/to/certificate.pdf',
]);

foreach ($response->output->documentResponses as $doc) {
    $doc->docId;
    $doc->documentType;
}
```

### Upload Letterhead/Signature Images

[](#upload-letterheadsignature-images)

```
use SmartDato\FedEx\Data\Document\ImageDocumentData;

$data = ImageDocumentData::from([
    'referenceId' => '1234',
    'name' => 'signature.png',
    'contentType' => 'image/png',
    'workflowName' => 'LetterheadSignature',
    'meta' => [
        'imageType' => 'SIGNATURE',
        'imageIndex' => 'IMAGE_1',
    ],
]);

$response = $fedex->documents()->uploadImage($data, '/path/to/signature.png');

$response->output->status;               // "SUCCESS"
$response->output->documentReferenceId;   // "1234"
```

### Using the Facade

[](#using-the-facade)

```
use SmartDato\FedEx\Facades\FedEx;

$response = FedEx::ship()->createShipment($request);
$labels = FedEx::documents()->uploadDocument($data, $filePath);
```

### On-the-fly Instantiation

[](#on-the-fly-instantiation)

Create instances without the Laravel container, useful for multiple accounts or non-Laravel usage:

```
use SmartDato\FedEx\FedEx;

$fedex = FedEx::make([
    'client_id' => 'your-client-id',
    'client_secret' => 'your-client-secret',
    'base_url' => 'https://apis-sandbox.fedex.com',
    'document_base_url' => 'https://documentapitest.prod.fedex.com/sandbox',
]);

$response = $fedex->ship()->createShipment($request);
```

### Accessing Raw Request/Response

[](#accessing-raw-requestresponse)

After any API call, you can inspect the raw Saloon request and response for debugging or logging:

```
$response = $fedex->ship()->createShipment($request);

$fedex->ship()->lastRequest();    // Saloon\Http\Request
$fedex->ship()->lastResponse();   // Saloon\Http\Response

// Same for documents
$fedex->documents()->lastRequest();
$fedex->documents()->lastResponse();
```

Available Enums
---------------

[](#available-enums)

The package provides typed enums for API constants:

```
use SmartDato\FedEx\Enums\PaymentType;       // SENDER, RECIPIENT, THIRD_PARTY, COLLECT
use SmartDato\FedEx\Enums\PickupType;        // CONTACT_FEDEX_TO_SCHEDULE, DROPOFF_AT_FEDEX_LOCATION, USE_SCHEDULED_PICKUP
use SmartDato\FedEx\Enums\WeightUnit;        // KG, LB
use SmartDato\FedEx\Enums\DimensionUnit;     // CM, IN
use SmartDato\FedEx\Enums\ImageType;         // ZPLII, EPL2, PDF, PNG
use SmartDato\FedEx\Enums\LabelStockType;    // PAPER_4X6, STOCK_4X675, PAPER_4X675, PAPER_4X8, PAPER_4X9, PAPER_7X475
use SmartDato\FedEx\Enums\LabelFormatType;   // COMMON2D, LABEL_DATA_ONLY
use SmartDato\FedEx\Enums\DeletionControl;   // DELETE_ALL_PACKAGES, DELETE_ONE_PACKAGE, LEGACY
use SmartDato\FedEx\Enums\ShipDocumentType;  // CERTIFICATE_OF_ORIGIN, COMMERCIAL_INVOICE, ETD_LABEL, ...
use SmartDato\FedEx\Enums\WorkflowName;      // ETDPreshipment, ETDPostshipment
use SmartDato\FedEx\Enums\CarrierCode;       // FDXE, FDXG
```

Error Handling
--------------

[](#error-handling)

API errors are thrown as `FedExApiException`:

```
use SmartDato\FedEx\Exceptions\FedExApiException;

try {
    $response = $fedex->ship()->createShipment($request);
} catch (FedExApiException $e) {
    $e->getMessage();       // Error message from the API
    $e->getCode();          // HTTP status code
    $e->errorCode;          // FedEx error code (e.g., "NOT.AUTHORIZED.ERROR")
    $e->transactionId;      // Transaction ID for support reference
}
```

Testing
-------

[](#testing)

```
composer test             # Run tests
composer analyse          # Static analysis (PHPStan level 5)
composer format           # Code style (Laravel Pint)
composer test-coverage    # Tests with coverage report
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [SmartDato](https://github.com/smart-dato)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

37

—

LowBetter than 82% of packages

Maintenance95

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

60d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c3006db55caec62526937fa2d941da32fc5e69e2ca86a52e87c8046da5958d82?d=identicon)[smart-dato](/maintainers/smart-dato)

---

Top Contributors

[![tschigo](https://avatars.githubusercontent.com/u/344100?v=4)](https://github.com/tschigo "tschigo (2 commits)")

---

Tags

laravelSmartDatofedex-rest-sdk

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/smart-dato-fedex-rest-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/smart-dato-fedex-rest-sdk/health.svg)](https://phpackages.com/packages/smart-dato-fedex-rest-sdk)
```

###  Alternatives

[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[tarfin-labs/event-machine

Event-driven state machines for Laravel with event sourcing, type-safe context, and full audit trail.

188.5k](/packages/tarfin-labs-event-machine)[basillangevin/laravel-data-json-schemas

Transforms Spatie Data objects into JSON Schemas with built-in validation

1312.2k1](/packages/basillangevin-laravel-data-json-schemas)[a2insights/filament-saas

Filament Saas for A2Insights

161.1k](/packages/a2insights-filament-saas)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
