> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zappway.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Datasource - Create

#### File upload supported mime types

* text/csv'
* text/plain'
* text/markdown'
* application/pdf'
* application/json'
* application/vnd.openxmlformats-officedocument.presentationml.presentation
* application/vnd.openxmlformats-officedocument.wordprocessingml.document
* application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

### Example JS Code to create a Datasource of type 'file'

```js theme={null}
const apiUrl = 'https://app.zappway.ai/api';
const apiKey = 'XXX';
const datastoreId = 'XXX';

const fileName = 'test.pdf';
const buffer = fs.readFileSync(fileName);

const formData = new FormData();

formData.append(
  'file',
  new Blob([buffer], {
    type: 'application/pdf',
  }),
  fileName
);

formData.append('type', 'file');
formData.append('datastoreId', datastoreId);
formData.append('fileName', fileName);

const res = await fetch(`${apiUrl}/datasources`, {
  method: 'POST',
  body: formData,
  headers: {
    Authorization: `Bearer ${apiKey}`,
  },
});
```

### Example JS Code to create a Datasource of type 'web\_page'

```js theme={null}
const apiUrl = 'https:/app.zappway.ai/api';
const apiKey = 'XXX';
const datastoreId = 'XXX';

const res = await fetch(`${apiUrl}/datasources`, {
  method: 'POST',
  body: JSON.stringify({
    datastoreId,
    type: 'web_page',
    name: 'Nuclear Fusion - Wikipedia',
    config: {
      source_url: 'https://en.wikipedia.org/wiki/Nuclear_fusion',
    },
  }),
  headers: {
    ContentType: 'application/json',
    Authorization: `Bearer ${apiKey}`,
  },
});
```

### Example JS Code to create a Datasource of type 'web\_site' with a sitemap

```js theme={null}
const apiUrl = 'https://app.zappway.ai';
const apiKey = 'XXX';
const datastoreId = 'XXX';

const res = await fetch(`${apiUrl}/datasources`, {
  method: 'POST',
  body: JSON.stringify({
    datastoreId,
    type: 'web_site',
    name: 'ZappWay Docs',
    config: {
      // Sitemap
      sitemap: 'https://docs.zappway.ai/en/sitemap.xml',

      // Or Auto Discovery
      source_url: 'https://docs.zappway.ai',
    },
  }),
  headers: {
    ContentType: 'application/json',
    Authorization: `Bearer ${apiKey}`,
  },
});
```


## OpenAPI

````yaml POST /datasources
openapi: 3.0.2
info:
  title: ZappWay - API OpenAPI specifications
  description: ''
  termsOfService: http://zappway.ai/terms
  contact:
    email: support@zappway.ai
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html
  version: 1.0.0
servers:
  - url: https://app.zappway.ai/api
security:
  - bearerAuth: []
tags:
  - name: agents
  - name: datastores
  - name: datasources
paths:
  /datasources:
    post:
      tags:
        - datasources
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  type: string
                  format: binary
                fileName:
                  type: string
                type:
                  enum:
                    - file
                datastoreId:
                  type: string
                custom_id:
                  type: string
                  description: Useful for multi-tenant setups
              required:
                - type
                - datastoreId
                - file
          application/json:
            schema:
              type: object
              properties:
                type:
                  enum:
                    - web_page
                    - web_site
                datastoreId:
                  type: string
                custom_id:
                  type: string
                  description: Useful for multi-tenant setups
                config:
                  type: object
                  properties:
                    source_url:
                      type: string
                      format: url
                      description: web_page, web_site
                    sitemap:
                      type: string
                      format: url
                      description: web_site
              required:
                - type
                - datastoreId
                - config
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Datasource'
        '400':
          description: Invalid body
        '403':
          description: Unauthorized
components:
  schemas:
    Datasource:
      type: object
      properties:
        id:
          type: string
        type:
          type: string
        name:
          type: string
        status:
          enum:
            - unsynched
            - pending
            - running
            - synched
            - error
            - usage_limit_reached
        groupId:
          type: string
        updatedAt:
          type: string
          format: date
        createdAt:
          type: string
          format: date
        lastSynch:
          type: string
          format: date
        config:
          type: object
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````