Skip To Content
ArcGIS Developers
Dashboard

/createService: Create Service

  • URL:https://[root]/content/users/[userName]/createService(POST only)

Example usage

ArcGIS Online URL for createService operation:

https://www.arcgis.com/sharing/rest/content/users/jsmith/createService

Below is a sample POST request for createService for ArcGIS Enterprise portal, formatted for readability:

POST /webadaptor/sharing/rest/content/users/jsmith/createService HTTP/1.1
Host: machine.domain.com
Content-Type: application/x-www-form-urlencoded
Content-Length: []

createParameters={
  "name": "EmptyServiceName",
  "serviceDescription": "",
  "hasStaticData": false,
  "maxRecordCount": 1000,
  "supportedQueryFormats": "JSON",
  "capabilities": "Create,Delete,Query,Update,Editing",
  "description": "",
  "copyrightText": "",
  "spatialReference": {
    "wkid": 102100
  },
  "initialExtent": {
    "xmin": -20037507.0671618,
    "ymin": -30240971.9583862,
    "xmax": 20037507.0671618,
    "ymax": 18398924.324645,
    "spatialReference": {
      "wkid": 102100,
      "latestWkid": 3857
    }
  },
  "allowGeometryUpdates": true,
  "units": "esriMeters",
  "xssPreventionInfo": {
    "xssPreventionEnabled": true,
    "xssPreventionRule": "input",
    "xssInputRule": "rejectInvalid"
  }
}&outputType=featureService&description=New Service&tags=empty, empty service&snippet=This is an empty service&f=json

Description

This operation allows users to create a hosted feature service. You can use the API to create an empty hosted feature service from a feature service metadata JSON.

Request parameters

ParameterDetails
[Common Parameters]

For a complete listing, see Common parameters.

createParameters

A JSON object specifying the properties of the newly created service. See the createParameters properties table below for further information.

outputType

The newly created service type.

Example

outputType=featureService
isView

Specifies if the request is generating a location tracking view. A view can only be created if there is already a Location Tracking Service that has been created.

Values: true | false

f

The response format. The default response format is json.

Values: html | json

createParameters properties

The createParameters JSON object is described in the table below. All properties are optional unless marked as required.

PropertyDescription
name

(Required)

Name of the service to be created. This name must be unique. If the name already exists, the operation will fail. ArcGIS Enterprise does not allow spaces or special characters other than underscores in a service name.

Example

"name": "EmptyServiceName"
serviceDescription

Description given to the service.

hasStaticData

Boolean value indicating whether the data changes.

Values: true | false

maxRecordCount

A double value indicating any constraints enforced on query operations.

Example

"maxRecordCount": 1000
supportedQueryFormats

The formats in which query results are returned.

Example

"supportedQueryFormats": "JSON"
capabilities

Specify feature service editing capabilities.

Values: Create | Delete | Query | Update | Sync

description

A user-friendly description for the published dataset.

copyrightText

Copyright information associated with the dataset.

spatialReference

All layers added to a hosted feature service need to have the same spatial reference defined for the feature service. When creating a new empty service without specifying its spatial reference, the spatial reference of the hosted feature service is set to the first layer added to that feature service.

Example

"spatialReference": {
  "wkid": 102100
}
initialExtent

The initial extent set for the service.

Example

"initialExtent" : {
  "xmin" : -20037507.0671618,
  "ymin" : -30240971.9583862,
  "xmax" : 20037507.0671618,
  "ymax" : 18398924.324645,
  "spatialReference" : {
    "wkid" : 102100,
    "latestWkid" : 3857
  }
}
allowGeometryUpdates

Boolean value indicating if updating the geometry of the service is permitted.

Values: true | false

units

Units used by the feature service.

Example

"units": "esriMeters"
xssPreventionInfo

A JSON object specifying the properties of cross-site scripting prevention. See the xxsPreventionInfo properties table below.

Example

"xssPreventionInfo": {
  "xssPreventionEnabled": true,
  "xssPreventionRule": "input",
  "xssInputRule": "rejectInvalid"
}

Caution:

The feature service fullExtent is a union of all its layers' extents. Adding a new layer to an existing feature service changes the feature service's fullExtent to include the new layer extent.

xxsPreventionInfo properties

PropertyDescription
xssPreventionEnabled

Boolean value indicating whether cross-site scripting prevention is enabled.

Values: true | false

xssPreventionRule

Specifies the prevention rule.

Values: input | inputOutput

xssInputRule

Specifies the input rule.

Values: rejectInvalid | sanitizeInvalid

Response properties

PropertyDetails
encodedServiceURL

The encoded URL to the hosted service.

Example

"encodedServiceURL":"https://<server>.arcgis.com/J4hBlWAa0Sl7uI5e/arcgis/rest/services/NewServiceName/FeatureServer"
itemId

The unique ID for this item.

Example

"itemId":"eb55f55e8f60419dbbccabb60ece2af8"
name

Name of the service item.

Example

"name":"NewServiceName"
serviceItemId

The ID of the new service item.

Example

"serviceItemId":"eb55f55e8f60419dbbccabb60ece2af8"
serviceurl

The URL to the hosted service.

Example

"serviceurl":"https://<server>.arcgis.com/J4hBlWAa0Sl7uI5e/arcgis/rest/services/NewServiceName/FeatureServer"
size

The size of the item.

Example

"size":-1
success

Indicates if the operation was successful.

Example

"success":true
type

The type of service created.

Example

"type":"Feature Service"
description

The description of the new service item.

Example

"description":"New Service"
tags

The tags used to describe the service item.

Example

"tags":"Empty service"
snippet

Snippet or summary for the new service item.

Example

"snippet":"This is an empty service"

Example usage

ArcGIS Online URL for createService operation:

https://www.arcgis.com/sharing/rest/content/users/jsmith/createService

Below is a sample POST request for createService for ArcGIS Enterprise portal, formatted for readability:

POST /webadaptor/sharing/rest/content/users/jsmith/createService HTTP/1.1
Host: machine.domain.com
Content-Type: application/x-www-form-urlencoded
Content-Length: []

createParameters={
  "name": "EmptyServiceName",
  "serviceDescription": "",
  "hasStaticData": false,
  "maxRecordCount": 1000,
  "supportedQueryFormats": "JSON",
  "capabilities": "Create,Delete,Query,Update,Editing",
  "description": "",
  "copyrightText": "",
  "spatialReference": {
    "wkid": 102100
  },
  "initialExtent": {
    "xmin": -20037507.0671618,
    "ymin": -30240971.9583862,
    "xmax": 20037507.0671618,
    "ymax": 18398924.324645,
    "spatialReference": {
      "wkid": 102100,
      "latestWkid": 3857
    }
  },
  "allowGeometryUpdates": true,
  "units": "esriMeters",
  "xssPreventionInfo": {
    "xssPreventionEnabled": true,
    "xssPreventionRule": "input",
    "xssInputRule": "rejectInvalid"
  }
}&outputType=featureService&description=New Service&tags=empty, empty service&snippet=This is an empty service&f=json

JSON Request example

The following shows an example of the createParameters JSON used to create a new empty hosted feature service:

{
  "name": "EmptyServiceName",
  "serviceDescription": "",
  "hasStaticData": false,
  "maxRecordCount": 1000,
  "supportedQueryFormats": "JSON",
  "capabilities": "Create,Delete,Query,Update,Editing",
  "description": "",
  "copyrightText": "",
  "spatialReference": {
    "wkid": 102100
  },
  "initialExtent" : {
    "xmin" : -20037507.0671618,
    "ymin" : -30240971.9583862,
    "xmax" : 20037507.0671618,
    "ymax" : 18398924.324645,
    "spatialReference" : {
      "wkid" : 102100,
      "latestWkid" : 3857
    }
  },
  "allowGeometryUpdates" : true,
  "units" : "esriMeters",
  "xssPreventionInfo" : {
    "xssPreventionEnabled" : true,
    "xssPreventionRule" : "input",
    "xssInputRule" : "rejectInvalid"
  }
}

JSON Response syntax

{
  "encodedServiceURL": <URL>,
  "itemId": "<item id>",
  "name": "<name of new service>",
  "serviceItemId": "<service id>",
  "serviceurl": "<url of service>",
  "size": "<size of new service>",
  "success": true | false,
  "type": "Feature Service",
  "description": "<description of the new service>",
  "tags": "<tags used for service>",
  "snippet": "<snippet given for service>"
}

JSON Response example

{
  "encodedServiceURL":"https://<server>.arcgis.com/J4hBlWAa0Sl7uI5e/arcgis/rest/services/NewServiceName/FeatureServer",
  "itemId":"eb55f55e8f60419dbbccabb60ece2af8",
  "name":"NewServiceName",
  "serviceItemId":"eb55f55e8f60419dbbccabb60ece2af8",
  "serviceurl":"https://<server>.arcgis.com/J4hBlWAa0Sl7uI5e/arcgis/rest/services/NewServiceName/FeatureServer",
  "size":-1,
  "success":true,
  "type":"Feature Service",
  "description":"New Service",
  "tags":"Empty service",
  "snippet":"This is an empty service"
}