Mark Fitzpatrick
Mark Fitzpatrick

Reputation: 15

PandaDOC API PHP issue

I have been pulling my hair out with the pandadoc API for sending our customers contracts.

I have been able to get it working and passing in the email and recipient information but I am unable to get it working adding in custom fields. I have tried a variety of ways.

Below is the request they say I need to make:

{
"name": "Sample Document",
"url": "URL_TO_A_DOCUMENT",
"recipients": [
    {
        "email": "[email protected]",
        "first_name": "John",
        "last_name": "Appleseed",
        "role":"u1"
    },
    ...
],
"fields": {
    "optId": {
        "title": "Field 1"
    }
 }
}

Here is what I have in my PHP:

function create_pandadoc($access_token, $array){ 

        $url = 'https://api.pandadoc.com/public/v1/documents';
        $docurl = "http://www.mydomain.co.uk/pandadoc/marktest.pdf";

        $postfields = array();
        $postfields['name'] = 'Contract Name';
        $postfields['url']  = $docurl;
        $postfields['recipients'] = array(
            array(
                'email'      => '[email protected]',
                'first_name' => 'John',
                'last_name'  => 'Appleseed',
                'role'       => 'u1'
            )
        );
       $postfields['fields'] = array(

            'plFirstname' => array(
                'First Name' =>  'John'

            )
            );

If I comment out the fields section - it goes through fine to the correct email and the customer is able to sign, but I need to be able to pass in the relavent custom fields too.

Here is a link to the API documentation.

https://developers.pandadoc.com/

Upvotes: 1

Views: 720

Answers (1)

tcastelli
tcastelli

Reputation: 35

Probably you solved that already, but for anyone looking for the answer, I found this to work:

"fields": {
   "fieldId": {
       "assignee": "[email protected]", // email of the person who has to fill the field (if needed)           
       "value": "The value for the field",
       "title": "Title for the field"
     }, 
...
}

Upvotes: 0

Related Questions