search mobile facets autocomplete spellcheck crawler rankings weights synonyms analytics engage api customize documentation install setup technology content domains user history info home business cart chart contact email activate analyticsalt analytics autocomplete cart contact content crawling custom documentation domains email engage faceted history info install mobile person querybuilder search setup spellcheck synonyms weights engage_search_term engage_related_content engage_next_results engage_personalized_results engage_recent_results success add arrow-down arrow-left arrow-right arrow-up caret-down caret-left caret-right caret-up check close content conversions-small conversions details edit grid help small-info error live magento minus move photo pin plus preview refresh search settings small-home stat subtract text trash unpin wordpress x alert case_deflection advanced-permissions keyword-detection predictive-ai sso

Custom API Sources, API Reference

Checkout the Custom API Sources Guide for a conceptual walkthrough.


Index, update, and destroy documents from a Custom API Source.

You can only create, update and destroy documents for a single Custom API source at a time

See the API Overview to learn about authentication and more.

Index and Update Documents

Index new objects into a custom content source or update documents that already exist.

Maximum 100 documents per request.

POST /api/v1/ent/sources/{content_source_key}/documents/bulk_create
access_token
required
Must be included in HTTP authorization headers.
content_source_key
required
Unique key for a Custom API source, provided upon creation of a Custom API Source.
title
required
Title or name of document being indexed.
url
required
Location of document being indexed.
body
required
Contents of the document. Serialize and pass descriptive and concise information related to the object, from file content to metadata. Supports arrays.
external_id
required
ID unique to a document used to identify, modify or delete the record at a later time. Learn more about External ID.
created_at
optional
An RFC3339 timestamp. Provides a document creation date and time.
updated_at
optional
An RFC3339 timestamp. Provides a document update date and time. You can filter on this parameter when searching or when sorting by Recently Updated.
type
optional
A string which describes the document. Used for filtering. An example might be "contract", "document", "report".
Example - A POST request to index documents.
curl -X POST http://localhost:3002/api/v1/ent/sources/[CONTENT_SOURCE_KEY]/documents/bulk_create \
-H "Authorization: Bearer [ACCESS_TOKEN]" \
-H "Content-Type: application/json" \
-d '[
  {
    "external_id" : 1234,
    "title" : "A List of Accounting Documents",
    "body" : "The difference between a budding entrepreneur who merely shows promise and one who is already enjoying some success often comes down to mentoring",
    "url" : "https://www.shopify.com/content/5-tips-on-finding-a-mentor",
    "created_at": "2019-06-01T12:00:00+00:00",
    "updated_at": "2018-07-11T12:00:00+00:00",
    "type": "list"
  }
]'
Example Response
[
  {
     "external_id":"1234",
     "errors":[]
  }
]

Example - A POST request to index documents.
No Java example available, showing cURL
curl -X POST http://localhost:3002/api/v1/ent/sources/[CONTENT_SOURCE_KEY]/documents/bulk_create \
-H "Authorization: Bearer [ACCESS_TOKEN]" \
-H "Content-Type: application/json" \
-d '[
  {
    "external_id" : 1234,
    "title" : "A List of Accounting Documents",
    "body" : "The difference between a budding entrepreneur who merely shows promise and one who is already enjoying some success often comes down to mentoring",
    "url" : "https://www.shopify.com/content/5-tips-on-finding-a-mentor",
    "created_at": "2019-06-01T12:00:00+00:00",
    "updated_at": "2018-07-11T12:00:00+00:00",
    "type": "list"
  }
]'
Example Response
No Java example available, showing cURL
[
  {
     "external_id":"1234",
     "errors":[]
  }
]

Example - A POST request to index documents.
const SwiftypeEnterpriseClient = require('swiftype-enterprise-node')

const accessToken = '' # Your access token const contentSourceKey = '' // Your content source key const documents = [ { external_id: 1234, title: "5 Tips On Finding A Mentor", body: "The difference between a budding entrepreneur who merely shows promise and one who is already enjoying some success often comes down to mentoring.", url: "https://www.shopify.com/content/5-tips-on-finding-a-mentor", "created_at": "2019-06-01T12:00:00+00:00", "updated_at": "2018-07-11T12:00:00+00:00", "type": "list" }, { external_id: 1235, title: "How to Profit from Your Passions", body: "Want to know the secret to starting a successful business? Find a void and fill it.", url: "https://www.shopify.com/content/how-to-profit-from-your-passions", "created_at": "2019-06-01T12:00:00+00:00", "updated_at": "2018-07-11T12:00:00+00:00", "type": "list" } ]

const swiftype = new SwiftypeEnterpriseClient(accessToken) swiftype.indexDocuments(contentSourceKey, documents) .catch((error) => { // handle error })

Example Response
[
  {
     "external_id":"1234",
     "errors":[]
  },
  {
     "external_id":"1235",
     "errors":[]
  },
]

Example - A POST request to index documents.
require 'swiftype-enterprise'

access_token = '' # Your access token content_source_key = '' # Your content source key documents = [ { 'external_id'=> 1234, 'url' => 'https://www.shopify.com/content/5-tips-on-finding-a-mentor', 'title' => '5 Tips On Finding A Mentor', 'body' => 'The difference between a budding entrepreneur who merely shows promise and one who is already enjoying some success often comes down to mentoring', 'created_at' => '2019-06-01T12:00:00+00:00', 'updated_at'=> '2018-07-11T12:00:00+00:00', 'type' => 'list' } ]

SwiftypeEnterprise.access_token = access_token client = SwiftypeEnterprise::Client.new begin ingest = client.index_documents(content_source_key, documents) rescue => e # handle error end

Example Response
[
  {
     "external_id":"1234",
     "errors":[]
  }
]

Example - A POST request to index documents.
from swiftype_enterprise import SwiftypeEnterpriseClient
from swiftype_enterprise.exceptions import SynchronousDocumentIndexingFailed

content_source_key = '' # Your content source key access_token = '' # Your access token client = SwiftypeEnterpriseClient(access_token) documents = [ { "external_id" : 1234, "title" : "5 Tips On Finding A Mentor", "body" : "The difference between a budding entrepreneur who merely shows promise and one who is already enjoying some success often comes down to mentoring", "url" : "https://www.shopify.com/content/5-tips-on-finding-a-mentor", "created_at": "2019-06-01T12:00:00+00:00", "updated_at": "2018-07-11T12:00:00+00:00", "type": "list" } ] try: ingest = client.index_documents(content_source_key, documents, timeout=10, delay=2) except SynchronousDocumentIndexingFailed: # Timed out before documents could finish indexing pass

Example Response
[
  {
     "external_id":"1234",
     "errors":[]
  }
]

Example - A POST request to index documents.
No Javascript example available, showing cURL
curl -X POST http://localhost:3002/api/v1/ent/sources/[CONTENT_SOURCE_KEY]/documents/bulk_create \
-H "Authorization: Bearer [ACCESS_TOKEN]" \
-H "Content-Type: application/json" \
-d '[
  {
    "external_id" : 1234,
    "title" : "A List of Accounting Documents",
    "body" : "The difference between a budding entrepreneur who merely shows promise and one who is already enjoying some success often comes down to mentoring",
    "url" : "https://www.shopify.com/content/5-tips-on-finding-a-mentor",
    "created_at": "2019-06-01T12:00:00+00:00",
    "updated_at": "2018-07-11T12:00:00+00:00",
    "type": "list"
  }
]'
Example Response
No Javascript example available, showing cURL
[
  {
     "external_id":"1234",
     "errors":[]
  }
]

Destroy Documents

Remove documents from a Custom API Source.

POST /api/v1/ent/sources/{content_source_key/documents/bulk_destroy
access_token
required
Must be included in HTTP authorization headers.
content_source_key
required
Unique key for a custom source, provided upon creation of a custom source.
external_id
required
An array of External IDs associated to documents to destroy.
Example - A POST request to delete documents.
curl -X POST http://localhost:3002/api/v1/ent/sources/[CONTENT_SOURCE_KEY]/documents/bulk_destroy \
-H "Authorization: Bearer [ACCESS_TOKEN]" \
-H "Content-Type: application/json" \
-d '[
  [DOCUMENT_ID_1], [DOCUMENT_ID_2]
]'
Example Response
[
 {
  "external_id":1234,
  "success":true
 },
 {
  "external_id":1235,
  "success":true
 }
]

Example - A POST request to delete documents.
No Java example available, showing cURL
curl -X POST http://localhost:3002/api/v1/ent/sources/[CONTENT_SOURCE_KEY]/documents/bulk_destroy \
-H "Authorization: Bearer [ACCESS_TOKEN]" \
-H "Content-Type: application/json" \
-d '[
  [DOCUMENT_ID_1], [DOCUMENT_ID_2]
]'
Example Response
No Java example available, showing cURL
[
 {
  "external_id":1234,
  "success":true
 },
 {
  "external_id":1235,
  "success":true
 }
]

Example - A POST request to delete documents.
const SwiftypeEnterpriseClient = require('swiftype-enterprise-node')

const accessToken = '' # Your access token const contentSourceKey = '' // your content source key const documentExternalIds = ['1234', '1235']

const swiftype = new SwiftypeEnterpriseClient(accessToken) swiftype.destroyDocuments(contentSourceKey, documentExternalIds) .then((destroyDocumentsResults) => { // handle destroy documents results }) .catch((error) => { // handle error })

Example Response
[
 {
  "external_id":1234,
  "success":true
 },
 {
  "external_id":1235,
  "success":true
 }
]

Example - A POST request to delete documents.
require 'swiftype-enterprise'

access_token = '' # Your access token content_source_key = '' # Your content source key document_external_ids = ['1234', '1235']

SwiftypeEnterprise.access_token = access_token client = SwiftypeEnterprise::Client.new begin destroy_document_results = client.destroy_documents(content_source_key, document_external_ids) # handle destroy document results rescue => e # handle error end

Example Response
[
 {
  'external_id' => 1234,
  'success' => 'true'
 },
 {
  'external_id' => 1235,
  'success' => 'true'
 }
]

Example - A POST request to delete documents.
from swiftype_enterprise import SwiftypeEnterpriseClient
from swiftype_enterprise.exceptions import SwiftypeEnterpriseError

content_source_key = '' # Your content source key access_token = '' # Your access token client = SwiftypeEnterpriseClient(access_token) try: response = client.destroy_documents(content_source_key, ['1234', '1235']) except SwiftypeEnterpriseError: # handle exception pass

Example Response
[
 {
  "external_id":1234,
  "success":true
 },
 {
  "external_id":1235,
  "success":true
 }
]

Example - A POST request to delete documents.
No Javascript example available, showing cURL
curl -X POST http://localhost:3002/api/v1/ent/sources/[CONTENT_SOURCE_KEY]/documents/bulk_destroy \
-H "Authorization: Bearer [ACCESS_TOKEN]" \
-H "Content-Type: application/json" \
-d '[
  [DOCUMENT_ID_1], [DOCUMENT_ID_2]
]'
Example Response
No Javascript example available, showing cURL
[
 {
  "external_id":1234,
  "success":true
 },
 {
  "external_id":1235,
  "success":true
 }
]


Enjoying the beta? Something broken? Lost? Please send us your feedback or visit the Enterprise Search community.