Developer Guide · PHP

How to add e-signatures
in PHP

Add legally binding e-signatures to a PHP app in four steps with the GetSigned REST API: get a token, create an envelope, send the signing link, and handle the completion webhook. Uses PHP's built-in cURL — no SDK or Composer package required.

Get free API keys →
1

Get a bearer token

Exchange your OAuth2 client credentials for a short-lived access token using PHP's built-in cURL extension.

php
<?php
$ch = curl_init('https://api.getsigned.app/oauth/token');
curl_setopt_array($ch, [
    CURLOPT_POST           => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POSTFIELDS     => http_build_query([
        'grant_type'    => 'client_credentials',
        'client_id'     => getenv('GETSIGNED_CLIENT_ID'),
        'client_secret' => getenv('GETSIGNED_CLIENT_SECRET'),
    ]),
]);
$token = json_decode(curl_exec($ch), true)['access_token'];
curl_close($ch);
2

Create an envelope

Upload the PDF and declare signers and fields with a multipart/form-data request using CURLFile.

php
$ch = curl_init('https://api.getsigned.app/v1/envelopes');
curl_setopt_array($ch, [
    CURLOPT_POST           => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER     => ["Authorization: Bearer $token"],
    CURLOPT_POSTFIELDS     => [
        'document' => new CURLFile('/path/to/nda.pdf', 'application/pdf'),
        'signers'  => json_encode([
            ['name' => 'Jamie', 'email' => 'jamie@client.io'],
        ]),
        'fields'   => json_encode([
            ['type' => 'signature', 'page' => 1, 'x' => 420, 'y' => 580],
        ]),
    ],
]);
$envelope = json_decode(curl_exec($ch), true);
// $envelope['id'] => 'env_...'
curl_close($ch);
3

Send for signing

Sending generates a tokenized, single-use link per signer and emails it. Signers verify identity with email/SMS OTP.

php
$envId = $envelope['id'];
$ch = curl_init("https://api.getsigned.app/v1/envelopes/{$envId}/send");
curl_setopt_array($ch, [
    CURLOPT_POST           => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER     => ["Authorization: Bearer $token"],
]);
curl_exec($ch);
curl_close($ch);
4

Handle the completion webhook

When the last signer finishes, GetSigned POSTs envelope.completed to your endpoint. Verify the HMAC-SHA256 signature, then download the sealed PDF from /v1/envelopes/{id}/document.

php
<?php
// webhook.php — registered at https://yourdomain.com/webhooks/getsigned

$raw    = file_get_contents('php://input'); // raw body, before json_decode
$sig    = $_SERVER['HTTP_X_GETSIGNED_SIGNATURE'] ?? '';
$secret = getenv('GETSIGNED_WEBHOOK_SECRET');
$expected = hash_hmac('sha256', $raw, $secret);

if (!hash_equals($expected, $sig)) {   // constant-time comparison
    http_response_code(401);
    exit;
}

$payload = json_decode($raw, true);

if (($payload['event'] ?? '') === 'envelope.completed') {
    $envelopeId = $payload['envelope_id'];
    // Fetch the sealed PDF and store it:
    // GET /v1/envelopes/$envelopeId/document
    // Update your database, notify users, etc.
}

http_response_code(200);

Frequently asked questions

How do I add e-signatures in PHP?

Use PHP's built-in cURL extension to call the GetSigned REST API: POST your client credentials to /oauth/token for a bearer token, create an envelope by POSTing a PDF with signers and fields as a multipart/form-data request using CURLFile, send it to generate signing links, then handle the envelope.completed webhook POST to fetch the sealed PDF. No SDK required.

Do I need a PHP SDK or Composer package?

No. GetSigned is a plain REST API, so PHP's built-in cURL extension handles the full integration. Any PHP web framework (Laravel, Symfony, Slim) can receive the completion webhook without additional libraries.

Does PHP's cURL support multipart file uploads?

Yes. Use CURLFile to attach the PDF as a multipart/form-data field. Set CURLOPT_POSTFIELDS to an array containing the CURLFile object alongside your JSON-encoded signers and fields strings — PHP and cURL handle the encoding automatically.

Is there a free tier to build against?

Yes. The free Starter plan includes full REST API access, PKCS#7 sealing, OTP verification, and webhooks, with 5 envelopes per month — enough to build and test a complete PHP integration.

Other stacks: Node.js guide · Python guide · Language-agnostic guide

Ship signing in your PHP app today

Get free API keys →