Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.paubox.com/llms.txt

Use this file to discover all available pages before exploring further.

The Forms client does not require API credentials. Forms are identified by a UUID that you obtain from the Paubox dashboard.

Instantiation

$forms = new Paubox\PauboxForms();

Get a form

Retrieve a form’s metadata, field schema, and rendered HTML/CSS:
$form = $forms->getForm("your-form-uuid");

echo $form->title . PHP_EOL;
echo $form->form_html . PHP_EOL;
print_r($form->form_json);
The returned stdClass includes:
PropertyDescription
titleDisplay name of the form
form_jsonParsed field schema
form_htmlRendered HTML for embedding
form_cssAssociated stylesheet
activeWhether the form is accepting submissions
submission_countNumber of submissions received
getForm throws \Exception if the form is not found or the response is invalid.

Submit a form

$submission = new Paubox\Forms\FormSubmission();
$submission->setFormData([
    "first_name" => "Jane",
    "last_name"  => "Smith",
    "email"      => "jane@example.com",
]);

$result = $forms->submitForm("your-form-uuid", $submission);
// $result === true on success
submitForm returns true on a successful submission (HTTP 201) and throws \Exception on failure with a message containing the HTTP status code and response body.

Submitting with file attachments

The maximum total request size is 250 MB.
$attachment = new Paubox\Forms\FormAttachment();
$attachment->setName("consent.pdf");
$attachment->setContent(base64_encode(file_get_contents("/path/to/consent.pdf")));

$submission = new Paubox\Forms\FormSubmission();
$submission->setFormData(["first_name" => "Jane"]);
$submission->setAttachments([$attachment]);

$result = $forms->submitForm("your-form-uuid", $submission);
The FormAttachment fields:
FieldDescription
nameFile name including extension
contentBase64-encoded file content

Error handling

Wrap calls in a try/catch block:
try {
    $form = $forms->getForm("your-form-uuid");
    $result = $forms->submitForm("your-form-uuid", $submission);
} catch (\Exception $e) {
    echo "Error: " . $e->getMessage() . PHP_EOL;
}