mifiel / api-client
Mifiel API Client for PHP
Requires
- php: >=8.3
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- mockery/mockery: ^1.6
- phpunit/phpunit: ^10.0
This package is not auto-updated.
Last update: 2026-08-25 17:19:07 UTC
README
PHP SDK for Mifiel API. Please read our documentation for instructions on how to start using the API.
Installation
Just run composer require mifiel/api-client in the root your project or add mifiel/api-client to your composer.json.
"require": { "mifiel/api-client": "^1.0" }
And then execute composer install.
Usage
For your convenience Mifiel offers a Sandbox environment where you can confidently test your code.
To start using the API in the Sandbox environment you need to first create an account at app-sandbox.mifiel.com.
Once you have an account you will need an APP_ID and an APP_SECRET which you can generate in app-sandbox.mifiel.com/settings/access-tokens.
Then you can configure the library with:
use Mifiel\ApiClient as Mifiel; Mifiel::setTokens('APP_ID', 'APP_SECRET'); // if you want to use our sandbox environment use: Mifiel::url('https://app-sandbox.mifiel.com/api/v1/');
By default setTokens points at production (https://app.mifiel.com/api/v1/).
Document methods:
-
Find:
use Mifiel\Document; $document = Document::find('id'); $document->original_hash; $document->file; $document->file_signed; # ...
-
Find all:
use Mifiel\Document; $documents = Document::all();
-
Create:
Use only original_hash if you dont want us to have the file.
Only file or original_hash must be provided.
use Mifiel\Document; $document = new Document([ 'file_path' => 'path/to/my-file.pdf', 'signatories' => [ [ 'name' => 'Signer 1', 'email' => 'signer1@email.com', 'tax_id' => 'AAA010101AAA' ], [ 'name' => 'Signer 2', 'email' => 'signer2@email.com', 'tax_id' => 'AAA010102AAA' ] ] ]); // if you dont want us to have the PDF, you can just send us // the original_hash and the name of the document. Both are required $document = new Document([ 'original_hash' => hash('sha256', file_get_contents('path/to/my-file.pdf')), 'name' => 'my-file.pdf', 'signatories' => ... ]); $document->save();
- Save Document related files
use Mifiel\Document; $document = Document::find('id'); # save the original file $document->saveFile('path/to/save/file.pdf'); # save the signed file (original file + signatures page) $document->saveFileSigned('path/to/save/file-signed.pdf'); # save the signed xml file $document->saveXML('path/to/save/xml.xml');
-
Delete
use Mifiel\Document; Document::delete('id');
Certificate methods:
-
Sat Certificates
use Mifiel\Certificate; $sat_certificates = Certificate::sat();
-
Find:
use Mifiel\Certificate; $certificate = Certificate::find('id'); $certificate->cer_hex; $certificate->type_of; # ...
-
Find all:
use Mifiel\Certificate; $certificates = Certificate::all();
-
Create
use Mifiel\Certificate; $certificate = new Certificate([ 'file_path' => 'path/to/my-certificate.cer' ]) $certificate->save();
-
Delete
use Mifiel\Certificate; Certificate::delete('id');
Template methods:
-
Find:
use Mifiel\Template; $template = Template::find('id'); $template->name; $template->header; $template->content; # ...
-
Find all:
use Mifiel\Template; $templates = Template::all();
-
Create:
use Mifiel\Template; $template = new Template([ 'name' => 'My template name', 'header' => 'Some header text', 'content' => '<div>The signer <field name="signer">SIGNER</field></div>', 'footer' => 'Some footer text' ]); $template->save(); $template->id;
-
Delete
use Mifiel\Template; Template::delete('id');
-
Generate a document from a template
use Mifiel\Document; $document = Document::createFromTemplate([ 'template_id' => 'some-id', 'name' => 'Some-name.pdf', 'fields' => [ 'name' => 'Signer 1', 'type' => 'Lawyer' ], 'signatories' => [[ 'email' => 'some@email.com' ]], 'external_id' => 'some-external-id' ]);
- Generate several documents from a template
$document = Document::createManyFromTemplate([ 'template_id' => 'some-id', 'identifier' => 'name', 'callback_url' => 'https://some-url.com', 'documents' => [[ 'fields' => [ 'name' => 'Signer 1', 'type' => 'Lawyer 1' ], 'signatories' => [[ 'email' => 'some1@email.com' ]], 'external_id' => 'some-other-external-id' ], [ 'fields' => [ 'name' => 'Signer 2', 'type' => 'Lawyer 2' ], 'signatories' => [[ 'email' => 'some2@email.com' ]], 'external_id' => 'some-other-external-id' ]] ]);
Development & Tests
We have two kinds of tests, unit and e2e (internet). You can run them with
# Unit php vendor/bin/phpunit --exclude-group internet # e2e php vendor/bin/phpunit --group internet
Contributing
- Fork it ( https://github.com/Mifiel/php-api-client/fork )
- Create your feature branch (
git checkout -b feature/my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin feature/my-new-feature) - Create a new Pull Request