Skip to content
StudyFetch API

Materials

Upload material from URL and wait for processing to complete

Fetches content from URL and waits for processing to finish before returning. Useful for synchronous API usage.

OpenAPI specification
POST/api/v1/materials/upload/url-and-process

Authentication

x-api-key

Request

curl --globoff --request POST \
  --url 'https://api.example.com/api/v1/materials/upload/url-and-process' \
  --header 'x-api-key: <API_KEY>' \
  --header 'Content-Type: application/json' \
  --data-raw '{
  "url": "https://example.com/document.pdf",
  "name": "My Document"
}'

Replace credential and <field> placeholders with your own values. URL placeholders appear as %3Cfield%3E. Review the example values before sending your request.

Replace https://api.example.com with the API server URL.

Use the sample JSON body as your starting point, and enter values that match the endpoint's schema.

Request body schema or example

{
  "type": "object",
  "properties": {
    "url": {
      "type": "string",
      "example": "https://example.com/document.pdf",
      "description": "URL to fetch content from"
    },
    "name": {
      "type": "string",
      "example": "My Document",
      "description": "Material name"
    },
    "folderId": {
      "type": "string",
      "description": "Folder ID (optional). If folderPath is provided, folderId will be ignored."
    },
    "folderPath": {
      "type": "string",
      "description": "Relative folder path (e.g., \"folder1/folder2\"). Folders will be created if they don't exist. The filename can be included (e.g., \"folder1/folder2/image1.png\") and will be extracted automatically."
    },
    "timeoutMs": {
      "type": "number",
      "default": 300000,
      "description": "Maximum time to wait for processing in milliseconds (default: 5 minutes)"
    },
    "pollIntervalMs": {
      "type": "number",
      "default": 2000,
      "description": "Polling interval in milliseconds (default: 2 seconds)"
    },
    "references": {
      "description": "References that this material cites",
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string",
            "example": "Understanding Photosynthesis",
            "description": "Reference title"
          },
          "url": {
            "type": "string",
            "example": "https://example.com/article",
            "description": "Reference URL"
          }
        },
        "required": [
          "title"
        ]
      }
    }
  },
  "required": [
    "url",
    "name"
  ]
}

Responses

201Material uploaded from URL and processed successfully
{
  "type": "object",
  "properties": {
    "_id": {
      "type": "string",
      "description": "Material ID"
    },
    "name": {
      "type": "string",
      "description": "Material name"
    },
    "organizationId": {
      "type": "string",
      "description": "Organization ID"
    },
    "folderId": {
      "type": "string",
      "description": "Folder ID",
      "nullable": true
    },
    "contentType": {
      "type": "string",
      "description": "Content type",
      "enum": [
        "text",
        "pdf",
        "video",
        "audio",
        "image",
        "epub"
      ]
    },
    "content": {
      "type": "object",
      "description": "Material content",
      "properties": {
        "text": {
          "type": "string"
        },
        "url": {
          "type": "string"
        },
        "s3Key": {
          "type": "string"
        },
        "s3Url": {
          "type": "string"
        },
        "filename": {
          "type": "string"
        },
        "fileSize": {
          "type": "number"
        },
        "mimeType": {
          "type": "string"
        }
      }
    },
    "metadata": {
      "type": "object",
      "description": "Material metadata"
    },
    "status": {
      "type": "string",
      "description": "Material status",
      "enum": [
        "active",
        "processing",
        "pending_upload",
        "error",
        "deleted"
      ]
    },
    "usage": {
      "type": "object",
      "description": "Usage information"
    },
    "references": {
      "description": "References that this material cites",
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string",
            "example": "Understanding Photosynthesis",
            "description": "Reference title"
          },
          "url": {
            "type": "string",
            "example": "https://example.com/article",
            "description": "Reference URL"
          }
        },
        "required": [
          "title"
        ]
      }
    },
    "createdAt": {
      "format": "date-time",
      "type": "string",
      "description": "Creation timestamp"
    },
    "updatedAt": {
      "format": "date-time",
      "type": "string",
      "description": "Last update timestamp"
    }
  },
  "required": [
    "_id",
    "name",
    "organizationId",
    "folderId",
    "contentType",
    "content",
    "status",
    "createdAt",
    "updatedAt"
  ]
}
400Invalid URL, processing failed, or timed out