---
updatedAt: 2026-08-25T16:15:22.000Z
agentTools:
  projectIndex: https://developers.jasper.ai/llms.txt
---

# Create a source

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.

# OpenAPI definition

```json
{
  "openapi": "3.1.0",
  "paths": {
    "/v1/context-sources": {
      "post": {
        "description": "Create a source that can be attached to a `CONTEXT_SOURCE_LIST` attribute on a Product (for example the universal `Images` attribute).\n\nSubmit 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.\n\nTake 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.",
        "operationId": "createContextSource",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/CreateContextSourceDto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Source created successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateContextSourceResponseDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad request. Missing required fields or unsupported file type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContextSource400Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized access to the workspace."
          },
          "403": {
            "description": "Product IQ is not enabled for this workspace."
          },
          "500": {
            "description": "Internal server error. Unable to create source.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContextSource500Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "X-API-Key": []
          },
          {
            "oauth2": [
              "user"
            ]
          }
        ],
        "summary": "Create a source",
        "tags": [
          "Context Sources"
        ]
      }
    }
  },
  "info": {
    "title": "Jasper API",
    "description": "Jasper API",
    "version": "1.0",
    "contact": {}
  },
  "tags": [
    {
      "name": "Context Sources",
      "description": ""
    }
  ],
  "servers": [
    {
      "url": "https://api.jasper.ai"
    }
  ],
  "components": {
    "securitySchemes": {
      "X-API-Key": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "Workspace authentication using API key tokens in the X-API-Key header."
      },
      "oauth2": {
        "type": "oauth2",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://api.jasper.ai/oauth2/authorize",
            "tokenUrl": "https://api.jasper.ai/oauth2/token",
            "refreshUrl": "https://api.jasper.ai/oauth2/token",
            "scopes": {
              "user:read": "Read user information",
              "user": "Read and write user information"
            }
          }
        },
        "description": "User-level authentication using OAuth bearer tokens in the Authorization header."
      }
    },
    "schemas": {
      "CreateContextSourceDto": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "FILE",
              "TEXT",
              "URL",
              "KNOWLEDGE"
            ],
            "description": "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": "FILE"
          },
          "value": {
            "oneOf": [
              {
                "title": "binary",
                "type": "string",
                "format": "binary"
              },
              {
                "title": "string",
                "type": "string"
              }
            ],
            "description": "The source payload. Its shape depends on `type`: for FILE, the binary file bytes (multipart file part; pick `binary` in the docs UI); for TEXT, a raw text string; for URL, a publicly reachable http(s) URL; for KNOWLEDGE, a Knowledge item ID (form field; pick `string`).",
            "example": "A short product description."
          }
        },
        "required": [
          "type",
          "value"
        ]
      },
      "ContextSourceResource": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The source ID. Reference this value when setting a `CONTEXT_SOURCE_LIST` attribute on a Product (e.g. `Images`) — note those attributes currently accept `FILE` sources only.",
            "example": "csc_2ee766eaa4ef48e59da1d9602bfecf2d"
          },
          "name": {
            "type": "string",
            "description": "The display name, derived at creation and not settable: the file name for an uploaded file, the URL for a URL, the first few words for text, or the item name for Knowledge.",
            "example": "widget-front.png"
          },
          "type": {
            "type": "string",
            "description": "The source type. On create this always matches the requested `type`.",
            "enum": [
              "FILE",
              "TEXT",
              "URL",
              "KNOWLEDGE"
            ],
            "example": "FILE"
          },
          "value": {
            "type": "string",
            "description": "The source URL for `URL` sources, or the wrapped Knowledge item ID for `KNOWLEDGE` sources. Omitted for `FILE` and `TEXT`, which hold their content in storage.",
            "example": "https://example.com/product"
          }
        },
        "required": [
          "id",
          "name",
          "type"
        ]
      },
      "CreateContextSourceResponseDto": {
        "type": "object",
        "properties": {
          "requestId": {
            "type": "string",
            "example": "8393f82b3f6a4f6e8a405777b9305254"
          },
          "resource": {
            "type": "string",
            "example": "knowledge"
          },
          "data": {
            "$ref": "#/components/schemas/ContextSourceResource"
          }
        },
        "required": [
          "requestId",
          "resource",
          "data"
        ]
      },
      "ContextSource400Error": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 400
          },
          "message": {
            "type": "string",
            "example": "Unsupported context source file type: .exe"
          },
          "error": {
            "type": "string",
            "example": "Bad Request"
          }
        },
        "required": [
          "statusCode",
          "message",
          "error"
        ]
      },
      "ContextSource500Error": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 500
          },
          "message": {
            "type": "string",
            "example": "Couldn't create source"
          },
          "error": {
            "type": "string",
            "example": "Internal Server Error"
          }
        },
        "required": [
          "statusCode",
          "message",
          "error"
        ]
      }
    }
  },
  "x-readme": {
    "metrics-enabled": false
  }
}
```