Back to New Client Onboarding Handoff

Integration and API Spec

The reference during the build: every tool connection, auth scope, field mapping, and error-handling rule.

4 pagesPDF · Technical
FS-DOC-05Technical

Integration and API Spec

New Client Onboarding Handoff

[YourCompany.com] · Sales Department · Prepared by FullSpec · [Today's Date]

This document provides the complete integration and API reference for the New Client Onboarding Handoff automation. It covers every tool in the stack, the exact OAuth scopes and webhook configurations required, field mappings between agents, orchestration layout, credential store contents, and defined error-handling behaviour for every integration point. The FullSpec team uses this specification as the authoritative source during build, testing, and ongoing maintenance. No credentials or sensitive values should be hardcoded anywhere in the workflow; all must be stored in the shared credential store as documented in Section 04.

01Tool inventory

Tool
Role in automation
Auth method
Min plan required
Used by agents
Orchestration layer
Hosts and executes all three agent workflows; manages credentials, retries, and scheduling
Internal service account
Any self-hosted or cloud tier with webhook ingress and credential store support
All agents
DocuSign
Trigger source: fires webhook on fully executed envelope; provides signed PDF download URL
OAuth 2.0 (Authorization Code)
Standard (eSignature API access required)
Agent 1
HubSpot
CRM data source and destination: deal stage update, field reads, audit note logging
OAuth 2.0 (Private App token)
Starter CRM or above (Deals API required)
Agents 1, 2, 3
Google Drive
Client folder creation from template; signed PDF storage and sharing
OAuth 2.0 (Authorization Code, service account for folder ops)
Google Workspace Business Starter or above
Agent 2
Notion
Client workspace creation from database template; population of deal data fields
OAuth 2.0 (Internal Integration Token)
Notion Plus or above (API access enabled)
Agent 2
Slack
Internal handoff brief delivery to delivery channel
OAuth 2.0 (Bot Token, incoming webhook URL)
Free tier or above (incoming webhooks enabled)
Agent 3
Gmail
Outbound client welcome email sent from account manager address
OAuth 2.0 (Authorization Code per sender account)
Google Workspace (sending on behalf of user requires delegated access or per-account OAuth)
Agent 3
Before you connect anything: stand up sandbox or test instances for every tool listed above and validate each connection using non-production credentials and dummy data. DocuSign provides a developer sandbox environment at account-d.docusign.com. HubSpot sandbox accounts are available on any paid tier. Google Drive and Gmail testing must use a dedicated test Google Workspace user, not a live account manager address. Notion API connections should be tested against a duplicate of the production database. Only after every sandbox connection is confirmed end to end should production credentials be entered into the credential store.
Integration and API SpecPage 1 of 4
FS-DOC-05Technical

02Per-tool integration detail

DocuSign

DocuSign acts as the sole trigger source for the entire automation. The orchestration layer registers a Connect webhook listener on the DocuSign account. When an envelope reaches the 'completed' status (both parties have signed), DocuSign POSTs an XML or JSON payload to the registered listener URL. The automation must validate the HMAC-SHA256 signature on every inbound webhook before processing.

Auth method
OAuth 2.0 Authorization Code flow. Client ID and Client Secret stored in credential store as DOCUSIGN_CLIENT_ID and DOCUSIGN_CLIENT_SECRET. Access tokens expire after 8 hours; refresh tokens are long-lived. Token refresh must be handled automatically by the orchestration layer.
Required scopes
signature extended impersonation spring_cm click.manage click.send webforms.instance.readonly webforms.instance.write webforms.read
Minimum scopes (this automation)
signature extended impersonation
Webhook / trigger setup
Create a DocuSign Connect configuration via Admin > Connect > Add Configuration. Set the trigger event to 'Envelope Completed'. Payload format: JSON. Include fields: envelopeId, status, signers, documents, customFields, emailSubject, completedDateTime. Listener URL: the orchestration layer's inbound webhook endpoint (stored as DOCUSIGN_WEBHOOK_URL). Enable HMAC authentication and store the shared secret as DOCUSIGN_HMAC_SECRET. Signature header: X-DocuSign-Signature-1.
Required configuration
Template envelope must include custom fields: client_name, deal_value, hubspot_deal_id, account_manager_email, scope_summary. These are mapped to HubSpot fields in Agent 1. The completed envelope's document download URL is constructed as: GET /v2.1/accounts/{accountId}/envelopes/{envelopeId}/documents/combined. Account ID stored as DOCUSIGN_ACCOUNT_ID.
Rate limits
DocuSign API: 1,000 calls/hour per account on Standard plan. At 18 envelopes/month the automation makes approximately 2 API calls per trigger (webhook receipt + document download). Monthly API usage: ~36 calls. Throttling is not required at current volume.
Constraints
HMAC signature validation is mandatory; unauthenticated payloads must be rejected with HTTP 401 and logged. Document download requires a separate authenticated GET after the webhook fires; the signed PDF URL in the webhook payload is not directly accessible without auth. Envelope must reach 'completed' status (not 'sent' or 'delivered') before the workflow proceeds.
// Inbound webhook payload (abbreviated)
{
  "envelopeId": "a1b2c3d4-...",
  "status": "completed",
  "completedDateTime": "2024-06-10T09:14:32Z",
  "emailSubject": "Your contract with [YourCompany.com]",
  "customFields": {
    "client_name": "Acme Corp",
    "deal_value": "12000",
    "hubspot_deal_id": "hs_deal_88821",
    "account_manager_email": "rep@yourcompany.com",
    "scope_summary": "Brand strategy and web redesign"
  },
  "documents": [{ "documentId": "1", "name": "Signed Agreement" }]
}
HubSpot

HubSpot is both a data destination (deal stage update, audit log) and a data source (client and contact fields used by Agents 2 and 3). The automation uses the HubSpot Private App token model rather than OAuth App, as no end-user OAuth consent is required for server-to-server deal operations.

Auth method
HubSpot Private App token. Token stored as HUBSPOT_PRIVATE_APP_TOKEN in the credential store. Passed as Authorization: Bearer {token} header on all requests. Tokens do not expire but must be rotated on any suspected compromise.
Required scopes
crm.objects.deals.read crm.objects.deals.write crm.objects.contacts.read crm.objects.contacts.write timeline crm.objects.owners.read
Webhook / trigger setup
HubSpot is not a trigger source in this automation. It is called via REST API. No HubSpot webhook subscription is required. Agent 1 writes to HubSpot; Agents 2 and 3 read from HubSpot using the deal ID passed from Agent 1.
Required configuration
The following custom deal properties must exist in HubSpot before build begins (create via Settings > Properties > Deal Properties if absent): hs_onboarding_status (enumeration: pending, in_progress, complete), contract_value (number), scope_summary (single-line text), account_manager_email (single-line text), notion_workspace_url (single-line text), drive_folder_url (single-line text). Deal pipeline must include a 'Closed Won' stage. Stage ID stored as HUBSPOT_CLOSED_WON_STAGE_ID.
Rate limits
HubSpot API: 100 requests/10 seconds, 250,000 requests/day on Starter. At 18 runs/month the automation makes approximately 8 API calls per run (1 update + 3 reads + 2 writes + 1 note + 1 owner lookup). Monthly usage: ~144 calls. Throttling is not required at current volume. Implement exponential backoff on 429 responses regardless.
Constraints
The hubspot_deal_id passed from the DocuSign webhook must be validated as an existing deal before any write operation. If the deal ID does not resolve, halt the workflow and alert via the error Slack channel. Owner lookup (crm.objects.owners.read) is required to resolve account_manager_email to a HubSpot owner record for the timeline note. Do not hardcode deal stage IDs; read HUBSPOT_CLOSED_WON_STAGE_ID from the credential store.
// PATCH /crm/v3/objects/deals/{dealId} — Agent 1 writes
{
  "properties": {
    "dealstage": "{HUBSPOT_CLOSED_WON_STAGE_ID}",
    "closedate": "2024-06-10",
    "contract_value": "12000",
    "scope_summary": "Brand strategy and web redesign",
    "account_manager_email": "rep@yourcompany.com",
    "hs_onboarding_status": "in_progress"
  }
}

// POST /crm/v3/objects/timeline/events — Agent 3 logs completion
{
  "objectType": "deals",
  "objectId": "hs_deal_88821",
  "eventTemplateId": "{HUBSPOT_ONBOARDING_EVENT_TEMPLATE_ID}",
  "tokens": { "status": "complete", "timestamp": "2024-06-10T09:17:45Z" }
}
Google Drive

Google Drive is used by Agent 2 to duplicate a master client folder template, rename it for the new client, upload the signed PDF from DocuSign, and share the folder with the delivery lead. A service account is used for folder operations so that no individual user's OAuth session is required for file manipulation.

Auth method
Google OAuth 2.0 service account (JSON key). Service account email stored as GDRIVE_SERVICE_ACCOUNT_EMAIL. JSON key file path stored as GDRIVE_SERVICE_ACCOUNT_KEY_PATH. The service account must be granted 'Editor' access to the master template folder and the parent 'Clients' folder where new folders are created.
Required scopes
https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/drive.file https://www.googleapis.com/auth/drive.metadata
Webhook / trigger setup
Google Drive is not a trigger source. Agent 2 calls the Drive API directly after receiving confirmation from Agent 1. No Drive push notification subscription is required for this automation.
Required configuration
Master template folder ID stored as GDRIVE_TEMPLATE_FOLDER_ID. Parent 'Clients' folder ID stored as GDRIVE_CLIENTS_PARENT_FOLDER_ID. Delivery lead Google account email stored as GDRIVE_DELIVERY_LEAD_EMAIL. Folder naming convention: '{client_name} — Onboarding — {YYYY-MM-DD}'. The signed PDF is uploaded using files.create with the MIME type application/pdf. After creation, the folder URL is written back to the HubSpot deal field drive_folder_url.
Rate limits
Google Drive API: 1,000 queries/100 seconds per user; 10,000,000 queries/day per project. At 18 runs/month the automation makes approximately 5 API calls per run (copy folder + rename + upload PDF + share + get URL). Monthly usage: ~90 calls. Throttling is not required at current volume.
Constraints
The service account must not be granted domain-wide delegation unless explicitly approved by the Google Workspace admin. Folder copy operations duplicate only the folder structure, not file contents, unless explicitly configured. Confirm the template folder contains only the desired subdirectory structure before enabling the copy operation. The signed PDF filename must be sanitised to remove special characters before upload.
// POST https://www.googleapis.com/drive/v3/files/{GDRIVE_TEMPLATE_FOLDER_ID}/copy
{ "name": "Acme Corp — Onboarding — 2024-06-10",
  "parents": ["{GDRIVE_CLIENTS_PARENT_FOLDER_ID}"] }

// POST https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart
// Uploads signed PDF to new folder

// POST https://www.googleapis.com/drive/v3/files/{newFolderId}/permissions
{ "role": "writer", "type": "user",
  "emailAddress": "{GDRIVE_DELIVERY_LEAD_EMAIL}" }
Notion

Notion is used by Agent 2 to create a new client workspace page by duplicating a template page within a designated Clients database. Deal data from HubSpot is used to populate database properties on the new page. The Notion internal integration token is used for all API calls.

Auth method
Notion Internal Integration Token. Token stored as NOTION_INTEGRATION_TOKEN. Passed as Authorization: Bearer {token} and Notion-Version: 2022-06-28 headers. The integration must be manually added to the Clients database and the template page within Notion (Share > Add connections).
Required scopes
read_content update_content insert_content read_user_with_email (set during integration creation in Notion settings; no granular scope strings are passed at runtime)
Webhook / trigger setup
Notion does not support outbound webhooks. Agent 2 writes to Notion via REST API only. No polling or subscription is required.
Required configuration
Notion Clients database ID stored as NOTION_CLIENTS_DATABASE_ID. Template page ID stored as NOTION_CLIENT_TEMPLATE_PAGE_ID. The new page is created using POST /v1/pages with parent.database_id set to NOTION_CLIENTS_DATABASE_ID. Template page properties are read first and used as a schema reference. Required database properties that must exist in the Notion database before build: Client Name (title), Deal Value (number), Scope Summary (rich text), Account Manager (email), Drive Folder URL (url), HubSpot Deal ID (rich text), Status (select: Active, Onboarding, Closed). The Notion workspace URL of the new page is written back to HubSpot field notion_workspace_url.
Rate limits
Notion API: 3 requests/second per integration. At 18 runs/month the automation makes approximately 4 API calls per run (read template + create page + update properties + get page URL). Monthly usage: ~72 calls. Throttling is not required at current volume. Implement 1-second delay between sequential Notion calls as a precaution.
Constraints
Notion's POST /v1/pages endpoint creates a new page but does not clone sub-page content from a template. If the template contains nested sub-pages (e.g. Brief, Deliverables, Contacts), those must either be created as additional POST /v1/pages calls or the template structure must be flattened to database properties only. Confirm template structure with the ops team before build. Rich text fields have a 2,000-character limit per block.
// POST https://api.notion.com/v1/pages
{
  "parent": { "database_id": "{NOTION_CLIENTS_DATABASE_ID}" },
  "properties": {
    "Client Name": { "title": [{ "text": { "content": "Acme Corp" } }] },
    "Deal Value": { "number": 12000 },
    "Scope Summary": { "rich_text": [{ "text": { "content": "Brand strategy and web redesign" } }] },
    "Account Manager": { "email": "rep@yourcompany.com" },
    "Drive Folder URL": { "url": "https://drive.google.com/drive/folders/..." },
    "HubSpot Deal ID": { "rich_text": [{ "text": { "content": "hs_deal_88821" } }] },
    "Status": { "select": { "name": "Onboarding" } }
  }
}
Slack

Slack is used by Agent 3 to post a structured handoff brief to the internal delivery channel. The automation uses an incoming webhook URL for simplicity and reliability. If richer interactivity is needed in future (e.g. acknowledgement buttons), a full Slack Bot Token can be substituted.

Auth method
Slack Incoming Webhook URL (no OAuth required for basic posting). Webhook URL stored as SLACK_DELIVERY_WEBHOOK_URL. For future interactive message support, Bot Token stored as SLACK_BOT_TOKEN with scopes chat:write chat:write.public channels:read.
Required scopes
Incoming webhook (current): no scopes required beyond webhook URL. Bot token (future): chat:write chat:write.public channels:read users:read users:read.email
Webhook / trigger setup
Create a Slack App in the workspace via api.slack.com/apps. Enable 'Incoming Webhooks'. Generate a webhook URL for the #delivery-handoffs channel (or equivalent). Store the URL as SLACK_DELIVERY_WEBHOOK_URL. The delivery channel name or ID is stored as SLACK_DELIVERY_CHANNEL_ID for future Bot Token use.
Required configuration
Message template must use Slack Block Kit JSON. Required blocks: header (client name), section (scope summary, deal value, account manager), two action links (Notion workspace URL, Drive folder URL). Template stored in the orchestration layer as a named template, not hardcoded in the workflow node. SLACK_DELIVERY_CHANNEL_ID stored in the credential store.
Rate limits
Slack incoming webhooks: 1 message/second per webhook. At 18 runs/month this automation sends 1 message per run. Monthly usage: 18 messages. Throttling is not required at current volume.
Constraints
Incoming webhook URLs are tied to a specific channel and cannot be redirected at runtime. If the delivery channel changes, a new webhook URL must be generated and SLACK_DELIVERY_WEBHOOK_URL updated. Slack message text fields support mrkdwn formatting only, not HTML. URLs must be verified to resolve before inclusion in the message payload to avoid broken links in the handoff brief.
// POST {SLACK_DELIVERY_WEBHOOK_URL}
{
  "blocks": [
    { "type": "header", "text": { "type": "plain_text", "text": "New Client Handoff: Acme Corp" } },
    { "type": "section", "fields": [
        { "type": "mrkdwn", "text": "*Scope:* Brand strategy and web redesign" },
        { "type": "mrkdwn", "text": "*Value:* $12,000" },
        { "type": "mrkdwn", "text": "*Account Manager:* rep@yourcompany.com" }
    ]},
    { "type": "section", "text": { "type": "mrkdwn",
      "text": "<{notion_url}|Notion Workspace>  |  <{drive_url}|Google Drive Folder>" } }
  ]
}
Gmail

Gmail is used by Agent 3 to send a personalised welcome email to the new client from the account manager's address. Because the email must appear to come from a named individual rather than a shared inbox, OAuth 2.0 must be authorised per account manager. If multiple account managers send welcome emails, each must complete the OAuth consent flow and their refresh token must be stored separately.

Auth method
Google OAuth 2.0 Authorization Code flow per sender account. Access token and refresh token stored per account manager as GMAIL_OAUTH_TOKEN_{MANAGER_ID}. Client ID and Client Secret shared across all sender accounts, stored as GMAIL_CLIENT_ID and GMAIL_CLIENT_SECRET. Token refresh handled automatically by the orchestration layer using the stored refresh token.
Required scopes
https://www.googleapis.com/auth/gmail.send https://www.googleapis.com/auth/gmail.compose https://www.googleapis.com/auth/userinfo.email
Webhook / trigger setup
Gmail is not a trigger source in this automation. Agent 3 calls the Gmail API (POST /gmail/v1/users/me/messages/send) after receiving the go-ahead from the workspace provisioning confirmation. No Gmail push notification is required.
Required configuration
Welcome email HTML template stored in the orchestration layer as GMAIL_WELCOME_TEMPLATE. Template placeholders: {{client_name}}, {{account_manager_name}}, {{scope_summary}}, {{notion_url}}, {{kickoff_scheduling_link}}. The account_manager_email field from HubSpot is used to select the correct stored OAuth token. The sender display name must match the account manager's full name as stored in GMAIL_SENDER_NAME_{MANAGER_ID}. Subject line template: 'Welcome to [YourCompany.com], {{client_name}}' stored as GMAIL_SUBJECT_TEMPLATE.
Rate limits
Gmail API: 250 quota units/user/second; sending via messages.send costs 100 units. Effective limit: ~2.5 sends/second per account. At 18 runs/month this automation sends 1 email per run per account manager. Monthly usage per sender: 18 sends. Throttling is not required at current volume.
Constraints
OAuth tokens are bound to the account manager's Google account. If the account manager leaves the organisation or revokes access, the token becomes invalid and the workflow will fail silently unless token validation is checked at workflow start. A token health check must be run weekly (see Section 05). Sending from a Google Workspace alias requires additional 'Send mail as' configuration in Gmail settings. Do not use a personal @gmail.com address for production sends.
// POST https://gmail.googleapis.com/gmail/v1/users/me/messages/send
// Authorization: Bearer {GMAIL_OAUTH_TOKEN_{MANAGER_ID}}
{
  "raw": "<base64url-encoded RFC 2822 message>"
}

// Decoded message headers:
// From: Alex Smith <rep@yourcompany.com>
// To: contact@acmecorp.com
// Subject: Welcome to [YourCompany.com], Acme Corp
// Content-Type: text/html; charset=UTF-8

// Body substitutions applied before encoding:
// {{client_name}}           -> Acme Corp
// {{account_manager_name}}  -> Alex Smith
// {{scope_summary}}         -> Brand strategy and web redesign
// {{notion_url}}            -> https://notion.so/...
// {{kickoff_scheduling_link}} -> https://calendly.com/...
Integration and API SpecPage 2 of 4
FS-DOC-05Technical

03Field mappings between tools

The following tables document every field handoff between tools across the three agent boundaries. Use exact field names as shown (monospace) when configuring the orchestration layer. Any field name mismatch will cause a silent null value, which may result in incomplete workspace records or blank email content.

Agent 1 handoff: DocuSign to HubSpot (Handoff Trigger Agent)

Source tool
Source field
Destination tool
Destination field
DocuSign
customFields.client_name
HubSpot
properties.dealname
DocuSign
customFields.deal_value
HubSpot
properties.contract_value
DocuSign
customFields.hubspot_deal_id
HubSpot
deal object ID (URL path param)
DocuSign
customFields.account_manager_email
HubSpot
properties.account_manager_email
DocuSign
customFields.scope_summary
HubSpot
properties.scope_summary
DocuSign
completedDateTime
HubSpot
properties.closedate
DocuSign
envelopeId
HubSpot
properties.hs_onboarding_status (set to: in_progress)
Hardcoded constant
HUBSPOT_CLOSED_WON_STAGE_ID
HubSpot
properties.dealstage

Agent 1 to Agent 2 handoff: HubSpot deal data passed to Workspace Provisioning Agent

Source tool
Source field
Destination tool
Destination field
HubSpot
properties.dealname
Google Drive
folder name (formatted: {client_name} — Onboarding — {date})
HubSpot
properties.dealname
Notion
properties.Client Name (title)
HubSpot
properties.contract_value
Notion
properties.Deal Value (number)
HubSpot
properties.scope_summary
Notion
properties.Scope Summary (rich_text)
HubSpot
properties.account_manager_email
Notion
properties.Account Manager (email)
HubSpot
deal object ID
Notion
properties.HubSpot Deal ID (rich_text)
DocuSign
signed PDF binary (fetched via envelopeId)
Google Drive
uploaded file in new client folder
Google Drive
new folder webViewLink
HubSpot
properties.drive_folder_url
Google Drive
new folder webViewLink
Notion
properties.Drive Folder URL (url)
Notion
new page url
HubSpot
properties.notion_workspace_url

Agent 2 to Agent 3 handoff: workspace URLs and deal data passed to Communications Agent

Source tool
Source field
Destination tool
Destination field
HubSpot
properties.dealname
Slack
blocks[0].text.text (header: client name)
HubSpot
properties.scope_summary
Slack
blocks[1].fields[0].text
HubSpot
properties.contract_value
Slack
blocks[1].fields[1].text
HubSpot
properties.account_manager_email
Slack
blocks[1].fields[2].text
HubSpot
properties.notion_workspace_url
Slack
blocks[2].text (Notion link)
HubSpot
properties.drive_folder_url
Slack
blocks[2].text (Drive link)
HubSpot
properties.dealname
Gmail
template placeholder {{client_name}}
HubSpot
properties.account_manager_email
Gmail
From header (sender selection)
HubSpot
properties.scope_summary
Gmail
template placeholder {{scope_summary}}
HubSpot
properties.notion_workspace_url
Gmail
template placeholder {{notion_url}}
HubSpot
contacts[0].email
Gmail
To header (recipient address)

04Build stack and orchestration

Orchestration layout
Three discrete workflows, one per agent, running within a single automation platform project. Workflows are chained by event: Agent 1 emits a completion event that triggers Agent 2; Agent 2 emits a completion event that triggers Agent 3. No shared in-memory state; all cross-agent data is read from HubSpot using the deal ID as the primary key.
Credential store
Single shared credential store accessible to all three workflows. All secrets and IDs are referenced by name (e.g. DOCUSIGN_CLIENT_ID) and never written inline in any workflow node. Credentials are encrypted at rest. Access is restricted to the automation platform service account only.
Agent 1 trigger mechanism
Webhook (push). DocuSign POSTs to the orchestration layer's registered listener URL on envelope completion. The listener validates the HMAC-SHA256 signature using DOCUSIGN_HMAC_SECRET before passing the payload to the workflow. No polling is used.
Agent 1 HMAC validation
Compute HMAC-SHA256 of the raw request body using DOCUSIGN_HMAC_SECRET. Compare to the value in the X-DocuSign-Signature-1 header. If mismatch, return HTTP 401 and log the event. Do not process the payload.
Agent 2 trigger mechanism
Internal event (push). Agent 1 emits a structured completion event containing the HubSpot deal ID and envelope ID. Agent 2 subscribes to this event type. No external webhook or polling is involved.
Agent 3 trigger mechanism
Internal event (push). Agent 2 emits a structured completion event containing the HubSpot deal ID, Drive folder URL, and Notion workspace URL. Agent 3 subscribes to this event type. No external webhook or polling is involved.
Retry and backoff
All HTTP calls use exponential backoff: initial delay 2 seconds, multiplier 2x, max 3 retries, max delay 30 seconds. After 3 failed retries, the step is marked as failed and an alert is sent to SLACK_ERROR_WEBHOOK_URL. Dead-letter logging is written to the platform's internal error log with full payload and error code.
Run volume
18 runs/month. No concurrency controls or queuing are required at current volume. Review if volume exceeds 100 runs/month.
Credential store reference — all keys must be populated before any workflow is activated
// Credential store contents — all values stored by key name, never hardcoded

// DocuSign
DOCUSIGN_CLIENT_ID              = "<OAuth App Client ID>"
DOCUSIGN_CLIENT_SECRET          = "<OAuth App Client Secret>"
DOCUSIGN_ACCOUNT_ID             = "<DocuSign Account GUID>"
DOCUSIGN_HMAC_SECRET            = "<Connect HMAC shared secret>"
DOCUSIGN_WEBHOOK_URL            = "<Orchestration layer inbound endpoint>"
DOCUSIGN_BASE_URL               = "https://na4.docusign.net/restapi"

// HubSpot
HUBSPOT_PRIVATE_APP_TOKEN       = "<Private App Bearer Token>"
HUBSPOT_CLOSED_WON_STAGE_ID     = "<Pipeline stage ID string>"
HUBSPOT_ONBOARDING_EVENT_TEMPLATE_ID = "<Timeline event template ID>"

// Google Drive
GDRIVE_SERVICE_ACCOUNT_EMAIL    = "automation@yourcompany.iam.gserviceaccount.com"
GDRIVE_SERVICE_ACCOUNT_KEY_PATH = "/secrets/gdrive-service-account.json"
GDRIVE_TEMPLATE_FOLDER_ID       = "<Master template folder ID>"
GDRIVE_CLIENTS_PARENT_FOLDER_ID = "<Parent Clients folder ID>"
GDRIVE_DELIVERY_LEAD_EMAIL      = "<Delivery lead Google Workspace email>"

// Notion
NOTION_INTEGRATION_TOKEN        = "<Internal Integration Secret>"
NOTION_CLIENTS_DATABASE_ID      = "<Notion database ID>"
NOTION_CLIENT_TEMPLATE_PAGE_ID  = "<Template page ID>"

// Slack
SLACK_DELIVERY_WEBHOOK_URL      = "https://hooks.slack.com/services/..."
SLACK_DELIVERY_CHANNEL_ID       = "<Channel ID e.g. C0123456789>"
SLACK_ERROR_WEBHOOK_URL         = "https://hooks.slack.com/services/..."

// Gmail (one entry per account manager)
GMAIL_CLIENT_ID                 = "<Google OAuth App Client ID>"
GMAIL_CLIENT_SECRET             = "<Google OAuth App Client Secret>"
GMAIL_OAUTH_TOKEN_{MANAGER_ID}  = "<Stored access + refresh token JSON per sender>"
GMAIL_SENDER_NAME_{MANAGER_ID}  = "<Display name e.g. Alex Smith>"
GMAIL_WELCOME_TEMPLATE          = "<Named template ID in orchestration layer>"
GMAIL_SUBJECT_TEMPLATE          = "Welcome to [YourCompany.com], {{client_name}}"
Integration and API SpecPage 3 of 4
FS-DOC-05Technical

05Error handling and retry logic

Unhandled exceptions must never fail silently. Every integration point must have a defined failure path. If a step exhausts all retries, an alert must be posted to the error Slack channel (SLACK_ERROR_WEBHOOK_URL) with the run ID, the failing step, the error code, and the HubSpot deal ID. A dead-letter log entry must also be written to the platform's internal error store.
Integration
Scenario
Required behaviour
DocuSign webhook receipt
HMAC signature validation fails
Return HTTP 401 immediately. Do not process payload. Log event with source IP and timestamp to error log. Post alert to SLACK_ERROR_WEBHOOK_URL. No retry; wait for DocuSign to resend (DocuSign retries failed webhooks up to 3 times over 72 hours with exponential backoff).
DocuSign webhook receipt
Payload missing required custom field (e.g. hubspot_deal_id is null or absent)
Halt workflow immediately. Log missing field name and envelopeId. Post alert to SLACK_ERROR_WEBHOOK_URL with envelope ID so a team member can manually retrieve the DocuSign custom fields and re-trigger the workflow via the manual override runbook.
DocuSign API — signed PDF download
Download returns HTTP 401, 403, or 404
Retry up to 3 times with exponential backoff (2s, 4s, 8s). If all retries fail, halt Agent 1 and post alert with envelopeId. The Drive folder and Notion page should still be created without the PDF; a follow-up manual upload step is flagged in the error notification.
HubSpot deal update (Agent 1)
Deal ID from DocuSign does not resolve to an existing HubSpot deal
Halt Agent 1 immediately. Post alert to SLACK_ERROR_WEBHOOK_URL with envelopeId and the invalid deal ID value. Do not attempt to create a new HubSpot deal automatically. Require manual resolution before re-triggering.
HubSpot deal update (Agent 1)
PATCH request returns HTTP 429 (rate limit)
Pause 10 seconds and retry. Retry up to 3 times. If rate limit persists, queue the update and retry after 60 seconds. Log each retry attempt. If 3 retries at the 60-second interval all fail, post alert and mark step as failed for manual intervention.
HubSpot field read (Agents 2 and 3)
Required field returns null or empty string
Agent 2: if scope_summary or dealname is null, use placeholder text 'Details to be confirmed' and continue workflow. If account_manager_email is null, halt Agent 3 and post alert; Gmail cannot send without a sender identity. Log all null field occurrences to the error store.
Google Drive — folder copy
Service account lacks permission on template or parent folder
Retry once after 5 seconds. If permission error persists, halt Agent 2 and post alert with folder IDs and error message. Do not attempt to create the folder under an alternative path. Require a Google Workspace admin to correct permissions before re-running.
Google Drive — signed PDF upload
Upload fails after 3 retries (any HTTP 5xx or timeout)
Log failure and continue Agent 2 with a flag: pdf_uploaded = false. Post a note to the error Slack channel indicating the PDF must be manually uploaded. Do not halt the full workflow; Notion and Slack steps should still proceed.
Notion — page creation
API returns HTTP 400 (invalid property type or value)
Log the full error body including the offending property name and value. Halt Agent 2 Notion step. Post alert with deal ID and property error. Do not retry without fixing the data; a 400 is a structural error, not a transient failure. The Slack handoff and Gmail email may still proceed using the data already in memory.
Slack — webhook POST
Webhook URL returns HTTP 404 or 410 (URL rotated or deleted)
Retry once immediately. If it fails, log error and post to the fallback error channel using SLACK_ERROR_WEBHOOK_URL. If both fail, write the full handoff brief content to the error log in plain text so a team member can copy and post it manually. Never drop the handoff brief silently.
Gmail — OAuth token invalid or expired
Gmail API returns HTTP 401 on send attempt
Attempt one token refresh using the stored refresh token. If refresh succeeds, retry the send immediately. If refresh fails (token revoked or expired), halt Agent 3 Gmail step and post alert identifying which GMAIL_OAUTH_TOKEN_{MANAGER_ID} is invalid. Require the account manager to re-authorise via the OAuth consent flow. Log the failed send with full template content so it can be sent manually.
Gmail — send returns HTTP 429 or 500
Transient Gmail API error
Retry up to 3 times with exponential backoff (2s, 4s, 8s). If all retries fail, log failure and post alert. Do not send duplicate emails; mark the run as needing a manual send. Implement idempotency check using HubSpot deal ID before any retry to confirm the email was not already delivered.
HubSpot — audit log note (Agent 3)
Timeline event POST fails after 3 retries
Log failure to the error store but do not halt or alert the team. The audit note is non-critical; the client welcome email and Slack handoff have already been sent. Schedule one additional retry attempt after 5 minutes. If that also fails, flag for manual note entry on the deal timeline.
For support with any integration issue, configuration question, or credential problem, contact the FullSpec team at support@gofullspec.com. Include the run ID, the HubSpot deal ID, and the error message from the platform log in your message.
Integration and API SpecPage 4 of 4

More documents for this process

Every document generated for New Client Onboarding Handoff.

Launch Plan
Operations · Owner
View
ROI and Business Case
Finance · Owner
View
Process Runbook / SOP
Operations · Owner
View
Developer Handover Pack
Technical · Developer
View
Test and QA Plan
Quality · Developer
View