---
title: "PHP"
description: "The official INBIO SDK for PHP — modern, typed, zero dependencies."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.in.bio/llms.txt
> Use this file to discover all available pages before exploring further.

# PHP

Readonly typed models, named arguments, zero Composer dependencies
(uses `ext-curl`). PHP ≥ 8.1.

```bash
composer require inbio/inbio
```

## Shorten a URL (no account)

```php
use Inbio\Inbio;

$link = Inbio::shorten('https://example.com/very/long/url');
echo $link->short_url; // https://in.bio/a8K2p
```

## Authenticated client

Pass a token or set `INBIO_API_TOKEN` in the environment:

```php
use Inbio\Client;

$client = new Client(); // reads INBIO_API_TOKEN

$created = $client->links->create(
'https://example.com/sale',
slug: 'spring-sale',
tags: ['marketing'],
utm: ['source' => 'newsletter', 'medium' => 'email'],
);
```

## Everything else

```php
// List with filters, or iterate every page automatically
$page = $client->links->list(status: 'active', perPage: 50);
foreach ($client->links->iterate(tag: 'marketing') as $link) {
echo $link->slug, ' ', $link->total_clicks, PHP_EOL;
}

// Update, toggle, delete
$client->links->update(42, title: 'Renamed');
$client->links->disable(42);
$client->links->enable(42);
$client->links->delete(42);

// QR code bytes → file
file_put_contents('qr.png', $client->links->qr(42, format: 'png', size: 1024));

// Analytics, folders, tags, usage
$stats = $client->links->analytics(42, from: '2026-06-01');
$folders = $client->folders->list();
$tags = $client->tags->list();
$usage = $client->account->usage();
```

## Errors

```php
use Inbio\Exception\RateLimitException;
use Inbio\Exception\ValidationException;

try {
$client->links->create($url);
} catch (ValidationException $e) {
print_r($e->errors);        // per-field messages
} catch (RateLimitException $e) {
echo $e->retryAfter;        // seconds
}
```

`AuthenticationException` (401), `AccessException` (403, plan or scope),
`NotFoundException`, `ValidationException`, `EntitlementException`,
`StateConflictException` (409), `RateLimitException` (429), `ServerException`
— all extend `Inbio\Exception\InbioException`. GETs and `Retry-After` 429s
are retried automatically with backoff.

## Webhooks

```php
$event = $client->webhooks->verify(
file_get_contents('php://input'),          // raw body
$_SERVER['HTTP_X_INBIO_SIGNATURE'],
$secret,
);
if ($event->event === 'link.clicked') {
// ...
}
```

Signatures are checked with `hash_equals` and a 5-minute replay-protection
window. See [Webhooks](/api/webhooks) for the payload format.

Source: https://docs.in.bio/sdks/php/index.mdx
