Download the PHP package rerout/sdk without Composer
On this page you can find all versions of the php package rerout/sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package sdk
Short Description Official PHP SDK for the Rerout branded-link API.
License MIT
Homepage https://rerout.co
Informations about the package sdk
rerout/sdk
Official PHP SDK for the Rerout API.
Branded link infrastructure on Cloudflare — create short links, render QR codes, read analytics, and verify webhook signatures.
Install
Requires PHP 8.2+ and the json and hash extensions. HTTP transport is
Guzzle 7.
Usage
API
Construction
A blank or missing API key throws a ReroutException with code
missing_api_key. The base_url has trailing slashes trimmed.
Links
UpdateLinkInput distinguishes three states per field:
- Leave alone — omit the argument (the default). The field is not sent.
- Set a value — pass a concrete value.
- Clear server-side — pass
UpdateLinkInput::CLEAR, which serialises as explicitnull.
Constructing an empty UpdateLinkInput and calling update() throws a
ReroutException (code bad_request) client-side — the request never leaves
your process.
Project
QR codes
Webhook endpoint management
Manage the project's webhook endpoints with an API key. The project is resolved
from the key — there is no project id in the path. The signingSecret is
returned once on create; store it to verify deliveries.
Webhook signature verification
Rerout signs every webhook delivery with an X-Rerout-Signature header in the
form t=<unix>,v1=<hex_hmac_sha256>. Verify it before trusting the payload:
The HMAC is SHA-256 over "<timestamp>.<raw_body>" and is compared in constant
time. The default timestamp tolerance is 300 seconds — pass
toleranceSeconds: 0 to disable the staleness check, or a custom value to
widen it. A $clock callable can be injected for testing.
Tags
Manage the project's tags with an API key. The project is resolved from the
key — there is no project id in the path. list() is the only call that
returns each tag's linkCount (live, non-deleted links the tag is attached
to); create/update return a plain Tag without it.
Error handling
Every API call throws Rerout\Exceptions\ReroutException on failure:
When the server returns a JSON error body, code and message are taken
verbatim. When it does not, a synthetic code is used:
| Condition | Code |
|---|---|
| HTTP 401 | unauthorized |
| HTTP 403 | forbidden |
| HTTP 404 | not_found |
| HTTP 429 | rate_limited |
| HTTP 5xx | server_error |
| other 4xx | client_error |
| connection failure | network_error |
| timeout | timeout |
| 2xx non-JSON body | unexpected_response |
Local development
License
MIT — see LICENSE.
Links
All versions of sdk with dependencies
ext-json Version *
ext-hash Version *
guzzlehttp/guzzle Version ^7.12.1
psr/http-message Version ^1.0 || ^2.0