Skip to content
Survey123 custom reports generated with the featureReport API
Create custom reports from Survey123 survey data using Word templates and the featureReport API.

You can programmatically create reports from your ArcGIS Survey123 survey data using the featureReport REST operation. Use Microsoft Word templates to create custom reports with maps, images, and formatted data. The API supports template creation, validation, report generation, and file downloads.

The featureReport operation provides these core operations:

OperationEndpointPurpose
Create Template/createSampleTemplateGenerate Word template with survey field placeholders
Validate Template/checkTemplateSyntaxCheck template syntax for errors
Generate Report/createReportSubmit report generation job
Check Status/jobs/{jobId}Monitor job progress
Download FilesJob response URLsRetrieve completed reports

Prerequisites

Before using the featureReport API, you need:

  • ArcGIS Account with Publisher or Administrator role
  • Survey123 feature layer with survey data
  • Access token for authentication
  • Word template (.docx) with survey data placeholders (optional)
  • Network access to Survey123 API endpoints
  • Understanding of REST API concepts and authentication

How to create custom reports with Feature Report API

To create custom reports with the Feature Report API, you use the REST API endpoints to generate Word or PDF reports from your Survey123 survey data. The API provides template creation, validation, report generation, and file download capabilities for creating professional reports with maps, images, and formatted data.

The general steps are:

  1. Create or upload template: Generate a sample template or upload your Word template with survey data placeholders
  2. Validate template: Check template syntax to catch errors before report generation
  3. Submit report job: Send report generation request with feature layer, template, and query parameters
  4. Monitor and download: Check job status and download completed reports

Feature Report API interface

The Feature Report API provides REST endpoints for creating custom reports from Survey123 data. You work with Word templates containing placeholders for survey fields and use the API to generate reports in Word or PDF format.

Key API components:

  • Template management: Create sample templates and validate custom templates
  • Report generation: Submit jobs to generate reports from survey data
  • Job monitoring: Track report generation progress and handle completion
  • File downloads: Retrieve completed reports in various formats

API endpoints and operations

The Feature Report API provides these core operations:

Use dark colors for code blocksCopy
1
https://survey123.arcgis.com/api/featureReport/

Available operations:

  • /createSampleTemplate - Generate Word template with survey field placeholders
  • /checkTemplateSyntax - Validate template syntax for errors
  • /createReport - Submit report generation job
  • /jobs/{jobId} - Monitor job progress and status
  • Job response URLs - Download completed reports

Template configuration options

When creating custom reports with the Feature Report API, you can configure various options:

Template settings:

  • Word document format (.docx) with survey field placeholders
  • Custom branding and organization styling
  • Conditional visibility for report sections
  • Image and map integration with size controls

Report parameters:

  • Output format (Word .docx or PDF)
  • Query parameters to select specific records
  • Batch processing for multiple reports
  • File packaging and naming options

Advanced features:

  • Related records (repeats) inclusion
  • Date and time formatting
  • Image size and quality controls
  • Map insertion with specific settings

Best practices

Follow these essential best practices for using the featureReport operation:

  • Validate templates before generating reports to catch syntax errors
  • Test with sample data before processing production surveys
  • Use batch processing for large datasets (max 1,000 records per job)
  • Monitor job status to handle failures gracefully
  • Optimize template size by removing unnecessary formatting and images

Code examples

Create a sample template

Generate a Word template with placeholders for all survey fields. This template serves as a starting point for customization.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Replace with your actual values
const featureLayerUrl = "https://services.arcgis.com/your_org/arcgis/rest/services/your_survey/FeatureServer/0";
const token = "YOUR_ACCESS_TOKEN";

// Prepare the form data
const formData = new FormData();
formData.append("featureLayerUrl", featureLayerUrl);
formData.append("token", token);
formData.append("outputFormat", "docx"); // or 'pdf'

// POST request to create sample template
fetch("https://survey123.arcgis.com/api/featureReport/createSampleTemplate", {
  method: "POST",
  body: formData
})
.then(response => {
  if (!response.ok) throw new Error("Network response was not ok");
  return response.blob();
})
.then(blob => {
  // Download the template file
  const url = window.URL.createObjectURL(blob);
  const a = document.createElement("a");
  a.style.display = "none";
  a.href = url;
  a.download = "Survey123_Sample_Template.docx";
  document.body.appendChild(a);
  a.click();
  window.URL.revokeObjectURL(url);
})
.catch(error => {
  console.error("Error creating template:", error);
});

Validate template syntax

Check your Word template for syntax errors before generating reports. This prevents job failures due to template issues.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Replace with your actual values
const featureLayerUrl = "https://services.arcgis.com/your_org/arcgis/rest/services/your_survey/FeatureServer/0";
const token = "YOUR_ACCESS_TOKEN";

// Get template file from file input
const fileInput = document.getElementById("templateFileInput");

fileInput.addEventListener("change", function(event) {
  const file = event.target.files[0];
  if (!file) {
    alert("Please select a template file (.docx).");
    return;
  }

  // Prepare form data
  const formData = new FormData();
  formData.append("templateFile", file);
  formData.append("featureLayerUrl", featureLayerUrl);
  formData.append("token", token);

  // POST request to validate template
  fetch("https://survey123.arcgis.com/api/featureReport/checkTemplateSyntax", {
    method: "POST",
    body: formData
  })
  .then(response => response.json())
  .then(result => {
    if (result.error) {
      console.error("Error:", result.error);
    } else if (result.syntaxErrors && result.syntaxErrors.length > 0) {
      console.error("Syntax errors:", result.syntaxErrors);
    } else {
      console.log("Template is valid");
    }
  })
  .catch(error => {
    console.error("Error checking template:", error);
  });
});

Generate reports

Submit a report generation job to create reports from your survey data. Monitor the job status and download completed reports.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Replace with your actual values
const featureLayerUrl = "https://services.arcgis.com/your_org/arcgis/rest/services/your_survey/FeatureServer/0";
const templateItemId = "YOUR_TEMPLATE_ITEM_ID";
const token = "YOUR_ACCESS_TOKEN";

// Build request payload
const payload = {
  featureLayerUrl,
  templateItemId,
  token,
  queryParameters: {
    objectIds: "1,2,3" // Generate reports for specific records
  },
  outputFormat: "pdf",
  outputReportName: "My_Report",
  packageFiles: true
};

// Submit report generation job
fetch("https://survey123.arcgis.com/api/featureReport/createReport", {
  method: "POST",
  headers: {
    "Content-Type": "application/json"
  },
  body: JSON.stringify(payload)
})
.then(response => response.json())
.then(result => {
  if (result.jobId) {
    console.log("Job submitted:", result.jobId);
    // Poll job status (see next example)
  } else if (result.error) {
    console.error("Error:", result.error.message);
  }
})
.catch(error => {
  console.error("Error submitting job:", error);
});

Monitor job status

Check the status of your report generation job and download completed reports.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Replace with your actual token
const token = "YOUR_ACCESS_TOKEN";

// Poll job status
function checkJobStatus(jobId) {
  fetch(`https://survey123.arcgis.com/api/featureReport/jobs/${jobId}?token=${token}`)
  .then(response => {
    if (!response.ok) throw new Error("Network response was not ok");
    return response.json();
  })
  .then(result => {
    console.log("Job status:", result.jobStatus);

    if (result.jobStatus === "esriJobSucceeded") {
      // Download completed reports
      result.resultFiles.forEach(file => {
        console.log("Download:", file.url);
        // Handle file download
        window.open(file.url, "_blank");
      });
    } else if (result.jobStatus === "esriJobFailed") {
      console.error("Job failed:", result.messages);
    } else if (result.jobStatus === "esriJobExecuting" || result.jobStatus === "esriJobSubmitted") {
      // Job still running, poll again after 5 seconds
      setTimeout(() => checkJobStatus(jobId), 5000);
    }
  })
  .catch(error => {
    console.error("Error checking job status:", error);
  });
}

// Start polling with job ID from report generation
checkJobStatus("your_job_id");

Tutorials

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.