Skip to main content
POST
/
items
/
{itemId}
/
resources
/
create
Create resource
curl --request POST \
  --url https://api.thehaystack.ai/v2/haystack/items/{itemId}/resources/create \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "title": "<string>",
  "contentType": "file",
  "subTitle": "<string>",
  "description": "<string>",
  "resourceTypeId": 123,
  "fileMimeType": "application/pdf",
  "fileSizeBytes": 1048576,
  "originalFilename": "<string>",
  "linkTarget": "<string>",
  "externalPlatform": "youtube",
  "externalPlatformId": "dQw4w9WgXcQ"
}
'
{
  "resource": {
    "id": 123,
    "itemId": 123,
    "title": "<string>",
    "subTitle": "<string>",
    "description": "<string>",
    "resourceTypeId": 123,
    "displayOrder": 123,
    "contentType": "file",
    "fileMimeType": "<string>",
    "fileSizeBytes": 123,
    "externalPlatform": "youtube",
    "externalPlatformId": "<string>",
    "thumbnailImgUrl": "<string>",
    "url": "<string>",
    "resourceType": {
      "id": 123,
      "name": "<string>"
    },
    "linkTarget": "<string>"
  },
  "uploadUrl": "https://s3.amazonaws.com/bucket/key?signature=..."
}

Authorizations

Authorization
string
header
required

Enter your API token from the Haystack dashboard

Path Parameters

itemId
integer
required

Body

application/json
title
string
required

Display title for the resource

contentType
enum<string>
required
Available options:
file,
link,
video
subTitle
string | null
description
string | null
resourceTypeId
integer | null

Category for grouping (see /resource-types)

fileMimeType
string

Required when contentType is file

Example:

"application/pdf"

fileSizeBytes
integer

Required when contentType is file

Example:

1048576

originalFilename
string

Original filename, used to choose an extension

Required when contentType is link

externalPlatform
enum<string>

Required when contentType is video

Available options:
youtube,
vimeo
externalPlatformId
string

Required when contentType is video

Example:

"dQw4w9WgXcQ"

Response

Resource created. For file content type, upload the file to uploadUrl via PUT to complete.

resource
object
uploadUrl
string | null

Presigned S3 URL for file uploads (PUT). Null for link and video resources.

Example:

"https://s3.amazonaws.com/bucket/key?signature=..."