Context Sources

Create a source

Changed on

Create a source that can be attached to a CONTEXT_SOURCE_LIST attribute on a Product (for example the universal Images attribute).

Submit as multipart/form-data. The type form field discriminates the payload carried on value: for FILE, send the file bytes as the value multipart part; for TEXT, URL, and KNOWLEDGE, send the payload as the value form field.

Take the id from the response and include it in the attribute value on a subsequent POST /v1/products or PATCH /v1/products/{productId} call. Attributes currently accept FILE sources only, and may narrow that further — the Images attribute takes PNG and JPEG — so a source created here is rejected at attach time if it does not qualify.

post/v1/context-sources

Request

  • Base URL
    https://api.jasper.ai
  • URL
    https://api.jasper.ai/v1/context-sources
  • Auth
    • API key in header X-API-Key
    • or OAuth 2
      Authorization code: https://api.jasper.ai/oauth2/authorize
      Token URL: https://api.jasper.ai/oauth2/token scopes: user

Request body multipart/form-data

type'FILE' | 'TEXT' | 'URL' | 'KNOWLEDGE' required

The kind of source being created. In every case the payload is carried on the value multipart part: FILE sends binary file bytes, the others send a string.

Example request

{
  "type": "FILE"
}

Response

Source created successfully.

requestIdstring required
resourcestring required

Example response

{
  "requestId": "8393f82b3f6a4f6e8a405777b9305254",
  "resource": "knowledge",
  "data": {
    "id": "csc_2ee766eaa4ef48e59da1d9602bfecf2d",
    "name": "widget-front.png",
    "type": "FILE",
    "value": "https://example.com/product"
  }
}

Changes