getForm and submitForm do not require API credentials. The form management methods require an API key with the forms scope (see Manage forms). Forms are identified by a UUID that you obtain from the Paubox dashboard.
Instantiation
Get a form
Retrieve a form’s metadata, field schema, and rendered HTML/CSS:getForm dies if the form UUID is invalid or the form is not found.
Submit a form
submitForm dies if the form ID or form data is invalid, or if the response has an errors key. Other API errors are returned rather than thrown: $result holds the error body, such as {"message":"Attachment content is not valid base64"}. Treat any non-empty $result as a failed submission.
Submitting with file attachments
The maximum total request size is 250 MB.
Pass
'' as the second argument to encode_base64. By default it adds a line break every 76 characters, and the API rejects base64 that contains line breaks.
Manage forms
These methods need aforms-scoped API key, sent as Authorization: Bearer YOUR_API_KEY. Create the client with Paubox_Forms_SDK->new('apiKey' => 'YOUR_API_KEY'), or set FORMS_API_KEY in config.cfg. Without a key they die. Call them as methods on the object.
Error handling
Wrap calls ineval to catch the errors that die, and check submitForm’s return value for the ones it returns: