Skip to content

Commit d32c60d

Browse files
Updating Turbosign docs to our latest features and types (#40)
* feat: added routes for turbosign single step route integration * feat: added CC email optional section to the setting up turboSign doc * feat: added turbosign bulk api integration
1 parent c4fbfbf commit d32c60d

43 files changed

Lines changed: 5705 additions & 370 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/TurboSign/API Bulk Signatures.md

Lines changed: 713 additions & 0 deletions
Large diffs are not rendered by default.

docs/TurboSign/API Signatures.md

Lines changed: 732 additions & 370 deletions
Large diffs are not rendered by default.

docs/TurboSign/Setting up TurboSign.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ For each recipient, you'll need:
199199

200200
![Add recipients interface showing all options](/img/turbosign/AddRecipients.png)
201201

202+
**CC Emails (Optional):** You can also add CC email addresses for people who should receive a copy of the document. These individuals will get the final signed copy when everyone has completed signing, but they won't need to sign the document themselves.
203+
202204
<br/>
203205

204206
:::tip Recipient Best Practices
69.6 KB
Loading

static/img/turbosign/api/types.svg

Lines changed: 19 additions & 0 deletions
Loading
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const fetch = require('node-fetch');
2+
3+
// Configuration - Update these values
4+
const API_TOKEN = "YOUR_API_TOKEN";
5+
const ORG_ID = "YOUR_ORGANIZATION_ID";
6+
const BASE_URL = "https://api.turbodocx.com";
7+
const BATCH_ID = "YOUR_BATCH_ID"; // Replace with actual batch ID to cancel
8+
9+
// Send POST request to cancel batch
10+
const response = await fetch(`${BASE_URL}/turbosign/bulk/batch/${BATCH_ID}/cancel`, {
11+
method: 'POST',
12+
headers: {
13+
'Authorization': `Bearer ${API_TOKEN}`,
14+
'x-rapiddocx-org-id': ORG_ID,
15+
'User-Agent': 'TurboDocx API Client',
16+
'Content-Type': 'application/json'
17+
}
18+
});
19+
20+
const result = await response.json();
21+
22+
if (result.success) {
23+
console.log('✅ Batch cancelled successfully');
24+
console.log('Batch ID:', result.batchId);
25+
console.log('Status:', result.status);
26+
console.log('\n📊 Cancellation Summary:');
27+
console.log('Cancelled Jobs:', result.cancelledJobs);
28+
console.log('Succeeded Jobs (already completed):', result.succeededJobs);
29+
console.log('Refunded Credits:', result.refundedCredits);
30+
console.log('\n💰 Credits have been refunded to your account for cancelled jobs');
31+
console.log('✅ Jobs that already succeeded remain completed');
32+
} else {
33+
console.error('❌ Error:', result.error || result.message);
34+
if (result.code) {
35+
console.error('Error Code:', result.code);
36+
}
37+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
const fetch = require('node-fetch');
2+
3+
// Configuration - Update these values
4+
const API_TOKEN = "YOUR_API_TOKEN";
5+
const ORG_ID = "YOUR_ORGANIZATION_ID";
6+
const BASE_URL = "https://api.turbodocx.com";
7+
const BATCH_ID = "YOUR_BATCH_ID"; // Replace with actual batch ID to cancel
8+
9+
// Fastify route handler example
10+
async function cancelBatch(request, reply) {
11+
try {
12+
// Send POST request to cancel batch
13+
const response = await fetch(`${BASE_URL}/turbosign/bulk/batch/${BATCH_ID}/cancel`, {
14+
method: 'POST',
15+
headers: {
16+
'Authorization': `Bearer ${API_TOKEN}`,
17+
'x-rapiddocx-org-id': ORG_ID,
18+
'User-Agent': 'TurboDocx API Client',
19+
'Content-Type': 'application/json'
20+
}
21+
});
22+
23+
const result = await response.json();
24+
25+
if (result.success) {
26+
return reply.send({
27+
success: true,
28+
batchId: result.batchId,
29+
status: result.status,
30+
message: result.message,
31+
cancelledJobs: result.cancelledJobs,
32+
succeededJobs: result.succeededJobs,
33+
refundedCredits: result.refundedCredits
34+
});
35+
} else {
36+
return reply.code(400).send({
37+
success: false,
38+
error: result.error || result.message,
39+
code: result.code
40+
});
41+
}
42+
} catch (error) {
43+
console.error('Error cancelling batch:', error);
44+
return reply.code(500).send({
45+
success: false,
46+
error: 'Internal server error',
47+
message: error.message
48+
});
49+
}
50+
}
51+
52+
// Export for use in Fastify app
53+
module.exports = { cancelBatch };
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import json
2+
import requests
3+
from fastapi import FastAPI, HTTPException
4+
from pydantic import BaseModel
5+
6+
# Configuration - Update these values
7+
API_TOKEN = "YOUR_API_TOKEN"
8+
ORG_ID = "YOUR_ORGANIZATION_ID"
9+
BASE_URL = "https://api.turbodocx.com"
10+
BATCH_ID = "YOUR_BATCH_ID" # Replace with actual batch ID to cancel
11+
12+
app = FastAPI()
13+
14+
class CancelBatchResponse(BaseModel):
15+
success: bool
16+
batchId: str
17+
status: str
18+
message: str
19+
cancelledJobs: int
20+
succeededJobs: int
21+
refundedCredits: int
22+
23+
@app.post('/cancel-batch', response_model=CancelBatchResponse)
24+
async def cancel_batch():
25+
try:
26+
# Prepare headers
27+
headers = {
28+
'Authorization': f'Bearer {API_TOKEN}',
29+
'x-rapiddocx-org-id': ORG_ID,
30+
'User-Agent': 'TurboDocx API Client',
31+
'Content-Type': 'application/json'
32+
}
33+
34+
# Send POST request to cancel batch
35+
response = requests.post(
36+
f'{BASE_URL}/turbosign/bulk/batch/{BATCH_ID}/cancel',
37+
headers=headers
38+
)
39+
40+
result = response.json()
41+
42+
if result.get('success'):
43+
return CancelBatchResponse(
44+
success=True,
45+
batchId=result['batchId'],
46+
status=result['status'],
47+
message=result['message'],
48+
cancelledJobs=result['cancelledJobs'],
49+
succeededJobs=result['succeededJobs'],
50+
refundedCredits=result['refundedCredits']
51+
)
52+
else:
53+
raise HTTPException(
54+
status_code=400,
55+
detail={
56+
'error': result.get('error', 'Failed to cancel batch'),
57+
'code': result.get('code')
58+
}
59+
)
60+
61+
except HTTPException:
62+
raise
63+
except Exception as error:
64+
print(f'Error cancelling batch: {error}')
65+
raise HTTPException(
66+
status_code=500,
67+
detail={
68+
'error': 'Internal server error',
69+
'message': str(error)
70+
}
71+
)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import json
2+
import requests
3+
from flask import Flask, jsonify
4+
5+
# Configuration - Update these values
6+
API_TOKEN = "YOUR_API_TOKEN"
7+
ORG_ID = "YOUR_ORGANIZATION_ID"
8+
BASE_URL = "https://api.turbodocx.com"
9+
BATCH_ID = "YOUR_BATCH_ID" # Replace with actual batch ID to cancel
10+
11+
app = Flask(__name__)
12+
13+
@app.route('/cancel-batch', methods=['POST'])
14+
def cancel_batch():
15+
try:
16+
# Prepare headers
17+
headers = {
18+
'Authorization': f'Bearer {API_TOKEN}',
19+
'x-rapiddocx-org-id': ORG_ID,
20+
'User-Agent': 'TurboDocx API Client',
21+
'Content-Type': 'application/json'
22+
}
23+
24+
# Send POST request to cancel batch
25+
response = requests.post(
26+
f'{BASE_URL}/turbosign/bulk/batch/{BATCH_ID}/cancel',
27+
headers=headers
28+
)
29+
30+
result = response.json()
31+
32+
if result.get('success'):
33+
return jsonify({
34+
'success': True,
35+
'batchId': result['batchId'],
36+
'status': result['status'],
37+
'message': result['message'],
38+
'cancelledJobs': result['cancelledJobs'],
39+
'succeededJobs': result['succeededJobs'],
40+
'refundedCredits': result['refundedCredits']
41+
}), 200
42+
else:
43+
return jsonify({
44+
'success': False,
45+
'error': result.get('error', 'Failed to cancel batch'),
46+
'code': result.get('code')
47+
}), 400
48+
49+
except Exception as error:
50+
print(f'Error cancelling batch: {error}')
51+
return jsonify({
52+
'success': False,
53+
'error': 'Internal server error',
54+
'message': str(error)
55+
}), 500
56+
57+
if __name__ == '__main__':
58+
app.run(debug=True)
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
const FormData = require('form-data');
2+
const fs = require('fs');
3+
const fetch = require('node-fetch');
4+
5+
// Configuration - Update these values
6+
const API_TOKEN = "YOUR_API_TOKEN";
7+
const ORG_ID = "YOUR_ORGANIZATION_ID";
8+
const BASE_URL = "https://api.turbodocx.com";
9+
10+
// Prepare documents array - each document represents one signing job
11+
const documents = [
12+
{
13+
recipients: [
14+
{
15+
name: 'John Smith',
16+
email: 'john.smith@company.com',
17+
signingOrder: 1
18+
}
19+
],
20+
fields: [
21+
{
22+
recipientEmail: 'john.smith@company.com',
23+
type: 'signature',
24+
page: 1,
25+
x: 100,
26+
y: 200,
27+
width: 200,
28+
height: 80,
29+
required: true
30+
},
31+
{
32+
recipientEmail: 'john.smith@company.com',
33+
type: 'date',
34+
page: 1,
35+
x: 100,
36+
y: 300,
37+
width: 150,
38+
height: 30,
39+
required: true
40+
}
41+
],
42+
documentName: 'Employment Contract - John Smith',
43+
documentDescription: 'Please review and sign your employment contract'
44+
},
45+
{
46+
recipients: [
47+
{
48+
name: 'Jane Doe',
49+
email: 'jane.doe@company.com',
50+
signingOrder: 1
51+
}
52+
],
53+
fields: [
54+
{
55+
recipientEmail: 'jane.doe@company.com',
56+
type: 'signature',
57+
page: 1,
58+
x: 100,
59+
y: 200,
60+
width: 200,
61+
height: 80,
62+
required: true
63+
},
64+
{
65+
recipientEmail: 'jane.doe@company.com',
66+
type: 'date',
67+
page: 1,
68+
x: 100,
69+
y: 300,
70+
width: 150,
71+
height: 30,
72+
required: true
73+
}
74+
],
75+
documentName: 'Employment Contract - Jane Doe',
76+
documentDescription: 'Please review and sign your employment contract'
77+
}
78+
];
79+
80+
// Create form data
81+
const formData = new FormData();
82+
formData.append('sourceType', 'file');
83+
formData.append('file', fs.createReadStream('./contract_template.pdf'));
84+
formData.append('batchName', 'Q4 Employment Contracts');
85+
formData.append('documentName', 'Employment Contract');
86+
formData.append('documentDescription', 'Please review and sign your employment contract');
87+
formData.append('senderName', 'HR Department');
88+
formData.append('senderEmail', 'hr@company.com');
89+
formData.append('documents', JSON.stringify(documents));
90+
91+
// Send request to bulk ingest endpoint
92+
const response = await fetch(`${BASE_URL}/turbosign/bulk/ingest`, {
93+
method: 'POST',
94+
headers: {
95+
'Authorization': `Bearer ${API_TOKEN}`,
96+
'x-rapiddocx-org-id': ORG_ID,
97+
'User-Agent': 'TurboDocx API Client',
98+
...formData.getHeaders()
99+
},
100+
body: formData
101+
});
102+
103+
const result = await response.json();
104+
105+
if (result.success) {
106+
console.log('✅ Bulk batch created successfully');
107+
console.log('Batch ID:', result.batchId);
108+
console.log('Batch Name:', result.batchName);
109+
console.log('Total Jobs:', result.totalJobs);
110+
console.log('Status:', result.status);
111+
console.log('\n📧 Documents will be sent to recipients asynchronously');
112+
console.log('💡 Tip: Use the batch ID to monitor progress and list jobs');
113+
} else {
114+
console.error('❌ Error:', result.error || result.message);
115+
if (result.code) {
116+
console.error('Error Code:', result.code);
117+
}
118+
if (result.data?.invalidDocuments) {
119+
console.error('Invalid Documents:', JSON.stringify(result.data.invalidDocuments, null, 2));
120+
}
121+
}

0 commit comments

Comments
 (0)