Simple API Client to integrate SignNow with your application or website. Sign documents, request e-signatures, and build role-based workflows with multiple signers: https://www.signnow.com/developers
- Requirements
- Install
- Setting up
- Entity manager
- Examples & use cases
- OAuth 2.0
- Document
- Upload document
- Upload document with text tags and convert them to fillable fields
- Retrieve document
- Delete document
- Download document
- Create a single-use link for document downloading
- Create a role-based invite to sign a document
- Create a simple free form invite to sign a document
- Cancel an invite to sign a document
- Create a signing link
- Add fillable fields to a document
- Template
- Document group
- Event subscriptions
PHP 7.1 or newer
composer require signnow/api-php-sdk
Register an annotation loader:
AnnotationRegistry::registerLoader('class_exists');
Prepare options for the Guzzle client. We recommend the following configuration:
$stack = HandlerStack::create();
$stack->setHandler(new CurlMultiHandler());
$stack->push(new AuthorizationMiddleware(new BasicToken($token))));
$stack->push(new ResponseCheckerMiddleware());
$options = [
'base_uri' => $host,
'headers' => ['Content-Type' => 'application/json'],
'connect_timeout' => 30,
'request_timeout' => 30,
'handler' => $stack,
];
Or you can use builder for configuring the default options:
$options = (new OptionBuilder())
->setUri($uri)
->useAuthorization($token)
->getOptions();
Create the instance of Entity Manager:
$entityManager = (new EntityManagerFactory())->createEntityManager($options);
Setup update http method for Entity Manager:
$entityManager->setUpdateHttpMethod(Request::METHOD_PUT);
Entity manager is the main class which controls communication with 3rd party REST API where JSON is used as main data type. It's responsible for saving objects to and fetching objects from the API.
Each entity is described by:
- API resource url (via HttpEntity annotation),
- API payload (via properties and theirs types),
- API response type (via ResponseType annotation, optional).
Upload Document to SignNow
$uploadFile = (new Document\Upload(new \SplFileInfo('realFilePath')));
$document = $entityManager->create($uploadFile);
Download Document from SignNow
$document = $entityManager->get(Document\Download::class, ['id' => $document_id], ['type' => 'collapsed']);
$entityManager->create(new TokenRequestPassword($username, $password));
$entityManager->get(Token::class);
$entityManager->create(new TokenRequestRefresh($refresh_token));
$entityManager->create(new Document\Upload(new \SplFileInfo($filePath)));
$entityManager->create(new Document\FieldExtract(new \SplFileInfo($filePath)));
$entityManager->get(Document\Document::class, ['id' => $document_id]);
$entityManager->delete(Document\Document::class, ['id' => $document_id]);
$entityManager->get(Document\Download::class, ['id' => $document_id], ['type' => 'collapsed']);
// type can be 'collapsed' or 'zip'
// if need table containing the document's history set with_history=1
$entityManager->get(Document\Download::class, ['id' => $document_id], ['type' => 'collapsed', 'with_history' => 1]);
$entityManager->create(new Document\DownloadLink(), ['id' => $document_id])
$to[] = new Recipient($recipient_email, $role, $roleId, $order);
$invite = new Invite($email, $to, $cc);
$entityManager->create($invite, ['documentId' => $document_id]);
$invite = (new Invite())
->setDocumentId($document_id)
->setTo($to)
->setFrom($from)
->setCc([])
->setSubject($subject)
->setMessage($message);
$entityManager->create($invite, ["documentId" => $document_id]);
$entityManager
->setUpdateHttpMethod(Request::METHOD_PUT)
->update(new CancelInvite(), ['documentId' => $document_id]);
$entityManager->create(new SigningLink($document_id));
$signature = (new SignatureField())
->setName('My Signature')
->setPageNumber(0)
->setRole('role 1')
->setRequired(true)
->setHeight(20)
->setWidth(10)
->setX(5)
->setY(10);
$text = (new TextField())
->setName('My text')
->setLabel('Some label')
->setPrefilledText('prefilled text')
->setPageNumber(0)
->setRole('role 1')
->setRequired(true)
->setHeight(20)
->setWidth(10)
->setX(100)
->setY(150);
$document = (new Document\Document())
->setId($document_id)
->setFields([$signature, $text]);
$entityManager->update($document);
$template = (new Template\Template())
->setDocumentId($document_id)
->setDocumentName($document_name);
$entityManager->create($template);
$templateCopy = (new Template\Copy())
->setTemplateId($template_id)
->setDocumentName($document_name);
$entityManager->create($templateCopy);
$entityManager->get(DocumentGroup\DocumentGroup::class, ['id' => $document_group_id])
$entityManager->delete(DocumentGroup\DocumentGroup::class, ['id' => $document_group_id])
$entityManager->create(
new DocumentGroup\GroupInvite\Cancel(),
[
'documentGroupId' => $documentGroupId,
'groupInviteId' => $groupInviteId
]
);
$entityManager->get(new EventSubscription\GetEventSubscriptions());
$entityManager->create(
(new EventSubscription\CreateEventSubscription())
->setEvent('document.update')
->setCallbackUrl('https://google.com.ua')
);
$entityManager->delete(
new EventSubscription\DeleteEventSubscription(),
['uniqueId' => $uniqueId]
);