Audit Service

This guide will cover how to use the audit service to get the audit information for a completed package.

The audit trail gives you a step-by-step documented history of a transaction for a document package (transaction in the UI).

The Code

You can download the complete sample code from the Developer Community Code Share, here.

The first step is to create your EslClient with your API_KEY and API_URL (remember to use apps instead of sandbox for production).

public static final String API_KEY = "YOUR_API_KEY";
public static final String API_URL = "https://sandbox.esignlive.com/api";

EslClient eslClient = new EslClient( API_KEY, API_URL );

Next, you will create a new PackageId object using a static packageId string. You would normally get this dynamically from somewhere, but this example uses a static value for simplicity.

PackageId packageId = new PackageId("COMPLETED_PACKAGE_ID");

Now, you will grab the list of Audit information and create your list iterator.

List<Audit> auditList = eslClient.getAuditService().getAudit(packageId);
Iterator<Audit> iter = auditList.iterator();

Finally, you can use a while loop to step through the list of Audit information. With each loop, the different property values are printed to the console.

while(iter.hasNext())
{
     Audit myaudit = iter.next();
     System.out.println("DateTime - " + myaudit.getDateTime() + ", Type - " + myaudit.getType() + ", User - " +     myaudit.getUser() + ", Email - " + myaudit.getEmail() + ", IP - " + myaudit.getIp() + ", Target - " + myaudit.getTarget() + ", Data - " + myaudit.getData());
}

The Output

When you execute your code, you will see each step of the audit trail for this package, as seen below. This is a .NET output, but the Java output will be essentially the same.

cSharpGetAuditOutput

Get the Code

The audit trail gives you a step-by-step documented history of a transaction for a document package (transaction in the UI).

The Code

You can download the full sample code from the Developer Community Code Share, here.

First, create your EslClient using the apiUrl (use apps instead of sandbox if using production instance) and apiKey (be sure to replace the marker with your key).

String apiUrl = "https://sandbox.esignlive.com/api";
String apiKey = "YOUR_API_KEY";
 
EslClient eslClient = new EslClient(apiKey, apiUrl);

You will also need a completed package’s ID. Normally you would dynamically grab this package ID from somewhere, but in this example, a static package ID is used. Simply replace the marker with a package ID of a completed package in your account.

PackageId packageId = new PackageId("COMPLETED_PACKAGE_ID");

The next two lines grab the list of Audit objects from the AuditService and create the enumerator used to step through the list.

List<Audit> myaudit = eslClient.AuditService.GetAudit(packageId);
List<Audit>.Enumerator myenum = myaudit.GetEnumerator();

Finally, you can use a while loop to walk through the list of Audit info. In this example, you write the different properties available out to the debug window.

while(myenum.MoveNext())
{
     Debug.WriteLine("DateTime - " + myenum.Current.dateTime + ", Type - " + myenum.Current.type + ", User - " +    myenum.Current.user + ", Email - " + myenum.Current.email + ", IP - " + myenum.Current.ip + ", Target - " + myenum.Current.target + ", Data - " + myenum.Current.data);
}

The Output

When you execute your code, you will see each step of the audit trail for this package, as seen below.

cSharpGetAuditOutput

Get the Code

The audit trail gives you a step-by-step documented history of a transaction for a document package (transaction in the UI).

The Code

You can download the complete sample code from the Developer Community Code Share, here.

To retrieve the audit trail of a package, you will need the package id, which is returned to you during package creation.

HTTP Request
GET /api/packages/{packageId}/audit

HTTP Headers
Accept: application/json
Content-Type: application/json
Authorization: Basic api_key

Response Payload

{
  "package-id": "c2e57376-7391-4559-8da9-5d0ed4a24c56",
  "audit-events": [
    {
      "type": "Signing Session For Signer",
      "date-time": "2016-04-20 14:14:51",
      "target": "signing url group",
      "user": "somegroup",
      "user-email": "9fe0d028-0572-4731-8520-99191340d78f@groups.esignlive.com",
      "user-ip": "11.11.111.111",
      "data": "Signing session to signer : 9fe0d028-0572-4731-8520-99191340d78f@groups.esignlive.com(somegroup"
    },
    {
      "type": "View",
      "date-time": "2016-04-20 14:14:54",
      "target": "doc1",
      "user": "somegroup",
      "user-email": "9fe0d028-0572-4731-8520-99191340d78f@groups.esignlive.com",
      "user-ip": "11.11.111.111",
      "data": null
    },
    {
      "type": "Click To Sign",
      "date-time": "2016-04-20 14:23:31",
      "target": "doc1",
      "user": "somegroup",
      "user-email": "9fe0d028-0572-4731-8520-99191340d78f@groups.esignlive.com",
      "user-ip": "11.11.111.111",
      "data": "Approval: FAPOezPt0H8E"
    },
    {
      "type": "View",
      "date-time": "2016-04-20 15:20:47",
      "target": "doc1",
      "user": "Haris Haidary",
      "user-email": "esl.signer1@example.com",
      "user-ip": "11.11.111.111",
      "data": null
    },
    {
      "type": "View",
      "date-time": "2016-04-20 15:23:52",
      "target": "doc1",
      "user": "Haris Haidary",
      "user-email": "esl.signer1@example.com",
      "user-ip": "11.11.111.111",
      "data": null
    },
    {
      "type": "View",
      "date-time": "2016-04-20 15:44:41",
      "target": "doc1",
      "user": "Haris Haidary",
      "user-email": "esl.signer1@example.com",
      "user-ip": "11.11.111.111",
      "data": null
    },
    {
      "type": "View",
      "date-time": "2016-04-20 15:44:47",
      "target": "doc1",
      "user": "Haris Haidary",
      "user-email": "esl.signer1@example.com",
      "user-ip": "11.11.111.111",
      "data": null
    }
  ]
}

Get the Code

The audit trail gives you a step-by-step documented history of a transaction for a document package (transaction in the UI).

The Code

To notice, some of the code is an extension of the APEX SDK and can be gotten through this code share.

First, you will grab the list of Audit information by the below encapsulated function by putting your package ID as the parameter.

public List<TestAuditService.Audit> getAudit(String packageId)

Then, you can use a for loop to step through the list of Audit information. With each loop, the different property values are printed to the console.

List<TestAuditService.Audit> auditList = getAudit(packageId);
for(TestAuditService.Audit audit: auditList){
    	System.debug('DateTime - ' + audit.date_time + ', Type - ' + audit.type + ', User - ' +  audit.user + ', Email -' + audit.user_email + ', IP - ' + audit.user_ip + ', Target - ' + audit.target + ', Data - ' + audit.data);
}

The Output

When you execute your code, you will see each step of the audit trail for this package, as seen below. This is what you can see from the Execution Log:

Capture

Get the Code