Sign in
agent:

List All Docusign Envelopes/Documents for the past 7 days

There was a problem that the LLM was not able to address. Please rephrase your prompt and try again.

Retrieve and display a list of envelopes/documents created in the last 7 days.

import requests from datetime import datetime, timedelta # Configuration base_url = "https://demo.docusign.net/restapi" # For production, use https://www.docusign.net/restapi # List documents in your account for the past 7 days def list_documents(): # Calculate the start date (7 days ago) and end date (current date) seven_days_ago = (datetime.now() - timedelta(days=7)).strftime("%Y-%m-%dT%H:%M:%SZ") today = datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ") url = f"{base_url}/v2.1/accounts/{account_id}/envelopes" headers = { "Authorization": f"Bearer {access_token}", "Content-Type": "application/json", } params = { "status": "completed", # Retrieve only completed envelopes "from_date": seven_days_ago, # Start date (7 days ago) "to_date": today, # End date (current date) } response = requests.get(url, headers=headers, params=params) if response.status_code == 200: envelopes = response.json().get("envelopes", []) if envelopes: print("List of envelopes/documents in your account for the past 7 days:") for envelope in envelopes: print(f"Envelope ID: {envelope['envelopeId']}") print(f"Document Name: {envelope.get('emailSubject', 'N/A')}") print(f"Status: {envelope['status']}") print(f"Created Date: {envelope['createdDateTime']}") print("-" * 30) else: print("No envelopes/documents found for the past 7 days.") else: print(f"Error retrieving documents: {response.status_code} - {response.text}") # Call the function to list documents list_documents()
copied