Introduction

Welcome to the MyDocumentsAccount documentation. This comprehensive guide will help you integrate and use our digital document signing platform effectively.

MyDocumentsAccount provides a powerful API and various SDKs to help you automate your document workflows, integrate with your existing systems, and create custom signing experiences for your users.

Whether you're looking to send documents for signature programmatically, create templates, manage users, or build a complete white-labeled signing solution, our documentation will guide you through the process.

Note

This documentation is for the latest version of the MyDocumentsAccount API (v2.0). If you're using an older version, please refer to the legacy documentation or consider upgrading to access the latest features.

Quick Start Guide

Get started with MyDocumentsAccount API in minutes. This guide will walk you through the basic steps to send your first document for signature programmatically.

Step 1: Get Your API Key

Log in to your MyDocumentsAccount account, go to Settings > API, and generate a new API key. Keep this key secure, as it provides access to your account.

Step 2: Install the SDK (Optional)

While you can use our REST API directly, our SDKs make integration easier. Install the SDK for your preferred language:

npm install MyDocumentsAccount-sdk
pip install MyDocumentsAccount-sdk
composer require MyDocumentsAccount/MyDocumentsAccount-sdk

Step 3: Send a Document for Signature

Here's a simple example of sending a document for signature using our JavaScript SDK:

// Initialize the SDK with your API key
const MyDocumentsAccount = require('MyDocumentsAccount-sdk');
const client = new MyDocumentsAccount.Client('YOUR_API_KEY');

// Send a document for signature
async function sendDocument() {
  try {
    const document = await client.documents.create({
      name: 'Contract Agreement',
      file: fs.readFileSync('path/to/document.pdf'),
      signers: [
        {
          email: 'signer@example.com',
          name: 'John Doe',
          role: 'Signer'
        }
      ],
      fields: [
        {
          type: 'signature',
          page: 1,
          x: 100,
          y: 100,
          width: 200,
          height: 50,
          signer: 0 // Index of the signer in the signers array
        }
      ]
    });
    
    console.log('Document sent successfully!');
    console.log('Document ID:', document.id);
    console.log('Signing URL:', document.signingUrl);
  } catch (error) {
    console.error('Error sending document:', error);
  }
}

sendDocument();

Step 4: Track Document Status

You can track the status of your document using the document ID:

async function getDocumentStatus(documentId) {
  try {
    const document = await client.documents.get(documentId);
    console.log('Document Status:', document.status);
    console.log('Signers:', document.signers);
  } catch (error) {
    console.error('Error getting document:', error);
  }
}

getDocumentStatus('document_id_here');

Authentication

All API requests to MyDocumentsAccount require authentication. We support two authentication methods:

API Key Authentication

The simplest way to authenticate is using your API key in the Authorization header:

curl -X GET https://api.MyDocumentsAccount.com/v2/documents \
  -H "Authorization: Bearer YOUR_API_KEY"

OAuth 2.0 Authentication

For more secure applications, especially those acting on behalf of users, we recommend using OAuth 2.0:

  1. Register your application in the MyDocumentsAccount Developer Portal
  2. Implement the OAuth 2.0 authorization flow to obtain an access token
  3. Use the access token in your API requests
curl -X GET https://api.MyDocumentsAccount.com/v2/documents \
  -H "Authorization: Bearer OAUTH_ACCESS_TOKEN"

For detailed instructions on implementing OAuth 2.0, refer to our OAuth 2.0 Guide.

API Overview

The MyDocumentsAccount API is organized around REST principles. It uses standard HTTP methods, returns JSON responses, and uses standard HTTP status codes to indicate the success or failure of requests.

Base URL

All API requests should be made to the following base URL:

https://api.MyDocumentsAccount.com/v2/

Request Format

For POST and PUT requests, the request body should be in JSON format with the Content-Type header set to application/json.

Response Format

All responses are returned in JSON format. A typical response structure looks like this:

{
  "data": {
    // Response data specific to the endpoint
  },
  "meta": {
    "pagination": {
      "total": 100,
      "count": 10,
      "per_page": 10,
      "current_page": 1,
      "total_pages": 10
    }
  }
}

Error Handling

When an error occurs, the API returns an appropriate HTTP status code and a JSON response with error details:

{
  "error": {
    "code": "invalid_request",
    "message": "The request was invalid",
    "details": [
      {
        "field": "email",
        "message": "Invalid email format"
      }
    ]
  }
}

Rate Limiting

The API has rate limits to ensure fair usage. The current limits are:

  • Basic Plan: 100 requests per minute
  • Professional Plan: 500 requests per minute
  • Enterprise Plan: 2000 requests per minute

Rate limit information is included in the response headers:

X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1620000000

Documents API

The Documents API allows you to create, send, and manage documents for signature.

Create a Document

Send a document for signature:

curl -X POST https://api.MyDocumentsAccount.com/v2/documents \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Contract Agreement",
    "file": "BASE64_ENCODED_FILE",
    "signers": [
      {
        "email": "signer@example.com",
        "name": "John Doe",
        "role": "Signer"
      }
    ],
    "fields": [
      {
        "type": "signature",
        "page": 1,
        "x": 100,
        "y": 100,
        "width": 200,
        "height": 50,
        "signer": 0
      }
    ]
  }'

Get a Document

Retrieve information about a specific document:

curl -X GET https://api.MyDocumentsAccount.com/v2/documents/DOCUMENT_ID \
  -H "Authorization: Bearer YOUR_API_KEY"

List Documents

Retrieve a list of documents:

curl -X GET https://api.MyDocumentsAccount.com/v2/documents \
  -H "Authorization: Bearer YOUR_API_KEY"

Cancel a Document

Cancel a document that has not been completed:

curl -X POST https://api.MyDocumentsAccount.com/v2/documents/DOCUMENT_ID/cancel \
  -H "Authorization: Bearer YOUR_API_KEY"

Remind Signers

Send a reminder to signers who have not yet signed:

curl -X POST https://api.MyDocumentsAccount.com/v2/documents/DOCUMENT_ID/remind \
  -H "Authorization: Bearer YOUR_API_KEY"

Download a Document

Download the signed document:

curl -X GET https://api.MyDocumentsAccount.com/v2/documents/DOCUMENT_ID/download \
  -H "Authorization: Bearer YOUR_API_KEY" \
  --output signed_document.pdf

Templates API

The Templates API allows you to create and manage reusable document templates.

Create a Template

Create a new template:

curl -X POST https://api.MyDocumentsAccount.com/v2/templates \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Employment Contract",
    "file": "BASE64_ENCODED_FILE",
    "roles": [
      {
        "name": "Employee",
        "order": 1
      },
      {
        "name": "Manager",
        "order": 2
      }
    ],
    "fields": [
      {
        "type": "signature",
        "page": 1,
        "x": 100,
        "y": 100,
        "width": 200,
        "height": 50,
        "role": "Employee"
      },
      {
        "type": "signature",
        "page": 1,
        "x": 100,
        "y": 200,
        "width": 200,
        "height": 50,
        "role": "Manager"
      }
    ]
  }'

Get a Template

Retrieve information about a specific template:

curl -X GET https://api.MyDocumentsAccount.com/v2/templates/TEMPLATE_ID \
  -H "Authorization: Bearer YOUR_API_KEY"

List Templates

Retrieve a list of templates:

curl -X GET https://api.MyDocumentsAccount.com/v2/templates \
  -H "Authorization: Bearer YOUR_API_KEY"

Use a Template

Create a document from a template:

curl -X POST https://api.MyDocumentsAccount.com/v2/templates/TEMPLATE_ID/use \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "John Doe Employment Contract",
    "signers": [
      {
        "email": "employee@example.com",
        "name": "John Doe",
        "role": "Employee"
      },
      {
        "email": "manager@example.com",
        "name": "Jane Smith",
        "role": "Manager"
      }
    ]
  }'

Users API

The Users API allows you to manage users in your MyDocumentsAccount account.

Create a User

Add a new user to your account:

curl -X POST https://api.MyDocumentsAccount.com/v2/users \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "user@example.com",
    "name": "John Doe",
    "role": "admin"
  }'

Get a User

Retrieve information about a specific user:

curl -X GET https://api.MyDocumentsAccount.com/v2/users/USER_ID \
  -H "Authorization: Bearer YOUR_API_KEY"

List Users

Retrieve a list of users in your account:

curl -X GET https://api.MyDocumentsAccount.com/v2/users \
  -H "Authorization: Bearer YOUR_API_KEY"

Update a User

Update a user's information:

curl -X PUT https://api.MyDocumentsAccount.com/v2/users/USER_ID \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "John Smith",
    "role": "member"
  }'

Delete a User

Remove a user from your account:

curl -X DELETE https://api.MyDocumentsAccount.com/v2/users/USER_ID \
  -H "Authorization: Bearer YOUR_API_KEY"

Webhooks

Webhooks allow you to receive real-time notifications when events occur in your MyDocumentsAccount account.

Available Events

  • document.created - A new document has been created
  • document.sent - A document has been sent for signature
  • document.viewed - A signer has viewed a document
  • document.signed - A signer has signed a document
  • document.completed - All signers have signed a document
  • document.declined - A signer has declined to sign a document
  • document.expired - A document has expired without being completed

Create a Webhook

Register a new webhook endpoint:

curl -X POST https://api.MyDocumentsAccount.com/v2/webhooks \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://your-server.com/webhook",
    "events": ["document.completed", "document.declined"],
    "secret": "your_webhook_secret"
  }'

Webhook Payload

When an event occurs, we'll send a POST request to your webhook URL with a JSON payload:

{
  "event": "document.completed",
  "data": {
    "document": {
      "id": "doc_123456",
      "name": "Contract Agreement",
      "status": "completed",
      "completed_at": "2023-05-01T12:00:00Z"
    }
  }
}

Verifying Webhooks

To ensure the webhook is coming from MyDocumentsAccount, we include a signature in the X-MyDocumentsAccount-Signature header. You should verify this signature using your webhook secret:

const crypto = require('crypto');

function verifyWebhookSignature(payload, signature, secret) {
  const hmac = crypto.createHmac('sha256', secret);
  const digest = hmac.update(payload).digest('hex');
  return crypto.timingSafeEqual(
    Buffer.from(digest),
    Buffer.from(signature)
  );
}

JavaScript SDK

Our JavaScript SDK provides a convenient way to interact with the MyDocumentsAccount API in Node.js and browser environments.

Installation

npm install MyDocumentsAccount-sdk

Usage

const MyDocumentsAccount = require('MyDocumentsAccount-sdk');

// Initialize the client
const client = new MyDocumentsAccount.Client('YOUR_API_KEY');

// Send a document for signature
async function sendDocument() {
  try {
    const document = await client.documents.create({
      name: 'Contract Agreement',
      file: fs.readFileSync('path/to/document.pdf'),
      signers: [
        {
          email: 'signer@example.com',
          name: 'John Doe',
          role: 'Signer'
        }
      ],
      fields: [
        {
          type: 'signature',
          page: 1,
          x: 100,
          y: 100,
          width: 200,
          height: 50,
          signer: 0
        }
      ]
    });
    
    console.log('Document sent successfully!');
    console.log('Document ID:', document.id);
  } catch (error) {
    console.error('Error sending document:', error);
  }
}

// List documents
async function listDocuments() {
  try {
    const { data, meta } = await client.documents.list({
      limit: 10,
      page: 1,
      status: 'pending'
    });
    
    console.log(`Found ${meta.pagination.total} documents`);
    data.forEach(doc => {
      console.log(`- ${doc.name} (${doc.status})`);
    });
  } catch (error) {
    console.error('Error listing documents:', error);
  }
}