Download the PHP package postbode/postbode-api without Composer
On this page you can find all versions of the php package postbode/postbode-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package postbode-api
Postbode API client for PHP
Official PHP client for version 2 of the Postbode.nu API: send letters, postcards and fulfillment orders, and follow them until they land on the doormat.
Full API reference: https://postbode.app/docs/api
Requirements
- PHP 8.2 or higher
- A PSR-18 HTTP client and a PSR-17 factory
Installation
If your project does not have an HTTP client yet, add one — Guzzle is the usual choice and needs no further configuration:
Already using Symfony's HttpClient, or a client of your own? Pass it in and skip the extra dependency.
Getting started
- Set up an account at https://postbode.nu
- Create an API token at https://postbode.app/gebruiker/api-tokens
To use a specific HTTP client rather than whichever one is discovered:
Sending a letter
Build the request, hand it to the API, and you get a fully typed item back.
The client base64-encodes your PDFs, so never do that yourself. addDocumentFromFile() reads them off disk,
addDocumentFromContents() takes bytes you already have in memory.
Every builder method returns a new instance, so a partly configured request is safe to keep as a template:
Creating a concept first
Leave out ->send(), or pass ->send(false), to create the item without shipping it. Check it, then release it:
Checking the price up front
Nothing is created and nothing is charged by asking.
Following an item
Your recipients can look an item up themselves with just its reference and their own postal code:
Endpoints
Every endpoint hangs off the client as a property.
| Property | Methods |
|---|---|
$postbode->mailboxes |
list(), get(), create() |
$postbode->postals |
list(), get(), create(), delete(), calculate(), send(), cancel(), performAction(), proof(), document(), logs(), findByV1Id() |
$postbode->envelopes |
listForMailbox(), get(), create(), delete(), pdf(), windowPreview() |
$postbode->products |
listForMailbox(), get() |
$postbode->tags |
listForMailbox(), get(), create() |
$postbode->paperTypes |
list() |
$postbode->address |
validate() |
$postbode->fulfillment |
create() |
$postbode->tracking |
track() |
Every endpoint that takes a request builder also accepts a plain array, if you would rather build the payload yourself:
Enums
Statuses, shipping methods and printing options are backed enums, each with a label() describing it in the
same words the API documentation uses.
Available: PostalStatus, PostalType, PostalAction, ShippingType, PostalPrinting, PostalPlex,
EnvelopeStatus, FulfillmentOrderStatus, TransactionType, TagColor.
Statuses on a resource keep both the typed enum and the raw value, so a status code introduced after this release still decodes:
Error handling
Failed calls throw; they never return a status code. Everything derives from PostbodeException, so one catch
covers the lot.
Upgrading from 1.x and 2.x
Version 3 is a rewrite against the v2 API and shares no method names with earlier releases. See UPGRADING.md for the full mapping, including how to translate the letter IDs you already stored into v2 UUIDs.
Examples
Runnable scripts live in examples/. Set POSTBODE_API_KEY and run one:
Contributing
License
MIT
All versions of postbode-api with dependencies
php-http/discovery Version ^1.19
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/http-message Version ^1.1|^2.0