Skip To Content
ArcGIS Developers
Dashboard

Truncate (Feature Layer)

Description

The truncate operation supports deleting all features or attachments in a hosted feature service layer. The result of this operation is a response indicating success or failure with error code and description.

Support for the truncate operation only applies if supportsTruncate is true on the layer metadata. The operation is supported on the layer admin API and can be invoked by a user who can administer the service. The truncate operation does not return deleted ID's and will reset the auto-increment column Objectid to 1. As well, the operation does not change the schema of the data (does not add, remove, or alter existing database columns, constraints, or indexes).

Note:

The following restrictions apply to the user of the layer truncate API:

  • It cannot be used when the layer is an origin in relationships with other layers.
  • It cannot be used to truncate layers that reference the same underlying database tables.
  • It cannot be used when sync is enabled.

Request parameters

ParameterDetails
attachmentOnly

Deletes all the attachments for this layer. None of the layer features will be deleted when attachmentOnly=true.

Value: true | false

async

Supports options for asynchronous processing. The default format is false. It is recommended to set async=true for larger datasets.

Value: true | false

f

The response format. The default response format is html.

Values: html | json | pjson

Example usage

Below is a sample URL used to access the truncate operation:

https://services.myserver.com/OrgID/ArcGIS/admin/services/countries-truncate.FeatureServer/0/truncate

JSON Response syntax

When attachmentOnly=true

{
  "success": <true|false>,
  "error": {
    "code": <code>,
    "message": "<description>",
    "details": [
      "<message>"
    ]
  }
}

JSON response example

When truncate succeeds

{
  "success": true
}

When truncate fails

{
  "error": {
    "code": 400, 
    "message": "", 
    "details": [
      "Unable to truncate layer data."
    ]
  }
}