# Import Courses

POST https://services.leadconnectorhq.com/courses/courses-exporter/public/import

Import Courses through public channels

## Authentication

None: this endpoint declares no security requirement, so no `Authorization` header is needed.

## Parameters

### Header Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `Version` | string | Yes | API Version |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "HighLevel API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/courses/courses-exporter/public/import": {
      "post": {
        "summary": "Import Courses",
        "operationId": "importCourses",
        "description": "Import Courses through public channels",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "required": true,
            "description": "API Version",
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicExporterPayload"
              }
            }
          }
        },
        "responses": {
          "default": {
            "description": "Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicExporterResponseDTO"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account.",
        "type": "http"
      },
      "Agency-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency (OR) Private Integration Token of Agency.",
        "type": "http"
      },
      "Agency-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency.",
        "type": "http"
      }
    },
    "schemas": {
      "PublicExporterPayload": {
        "type": "object",
        "properties": {
          "locationId": {
            "type": "string"
          },
          "userId": {
            "type": "string"
          },
          "products": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "title": {
                  "type": "string"
                },
                "description": {
                  "type": "string"
                },
                "imageUrl": {
                  "type": "string"
                },
                "categories": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "title": {
                        "type": "string"
                      },
                      "visibility": {
                        "type": "string",
                        "enum": [
                          "published",
                          "draft"
                        ],
                        "title": "visibility"
                      },
                      "thumbnailUrl": {
                        "type": "string"
                      },
                      "posts": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "title": {
                              "type": "string"
                            },
                            "visibility": {
                              "type": "string",
                              "enum": [
                                "published",
                                "draft"
                              ],
                              "title": "visibility"
                            },
                            "thumbnailUrl": {
                              "type": "string"
                            },
                            "contentType": {
                              "type": "string",
                              "enum": [
                                "video",
                                "assignment",
                                "quiz",
                                "funnel"
                              ],
                              "title": "contentType"
                            },
                            "description": {
                              "type": "string"
                            },
                            "bucketVideoUrl": {
                              "type": "string"
                            },
                            "postMaterials": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "title": {
                                    "type": "string"
                                  },
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "pdf",
                                      "image",
                                      "docx",
                                      "pptx",
                                      "xlsx",
                                      "html",
                                      "dotx",
                                      "epub",
                                      "webp",
                                      "gdoc",
                                      "mp3",
                                      "doc",
                                      "txt",
                                      "zip",
                                      "ppt",
                                      "key",
                                      "htm",
                                      "xls",
                                      "odp",
                                      "odt",
                                      "rtf",
                                      "m4a",
                                      "ods",
                                      "mp4",
                                      "ai",
                                      "avi",
                                      "mov",
                                      "wmv",
                                      "mkv",
                                      "wav",
                                      "flac",
                                      "ogg",
                                      "png",
                                      "jpeg",
                                      "jpg",
                                      "gif",
                                      "bmp",
                                      "tiff",
                                      "svg",
                                      "odg",
                                      "sxw",
                                      "sxc",
                                      "sxi",
                                      "rar",
                                      "7z",
                                      "json",
                                      "xml",
                                      "csv",
                                      "md",
                                      "obj",
                                      "stl",
                                      "woff",
                                      "ttf"
                                    ],
                                    "title": "type"
                                  },
                                  "url": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "title",
                                  "type",
                                  "url"
                                ],
                                "title": "PostMaterialInterface"
                              }
                            }
                          },
                          "required": [
                            "title",
                            "visibility",
                            "contentType",
                            "description"
                          ],
                          "title": "PostInterface"
                        }
                      },
                      "subCategories": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "title": {
                              "type": "string"
                            },
                            "visibility": {
                              "type": "string",
                              "enum": [
                                "published",
                                "draft"
                              ],
                              "title": "visibility"
                            },
                            "thumbnailUrl": {
                              "type": "string"
                            },
                            "posts": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "title": {
                                    "type": "string"
                                  },
                                  "visibility": {
                                    "type": "string",
                                    "enum": [
                                      "published",
                                      "draft"
                                    ],
                                    "title": "visibility"
                                  },
                                  "thumbnailUrl": {
                                    "type": "string"
                                  },
                                  "contentType": {
                                    "type": "string",
                                    "enum": [
                                      "video",
                                      "assignment",
                                      "quiz",
                                      "funnel"
                                    ],
                                    "title": "contentType"
                                  },
                                  "description": {
                                    "type": "string"
                                  },
                                  "bucketVideoUrl": {
                                    "type": "string"
                                  },
                                  "postMaterials": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "title": {
                                          "type": "string"
                                        },
                                        "type": {
                                          "type": "string",
                                          "enum": [
                                            "pdf",
                                            "image",
                                            "docx",
                                            "pptx",
                                            "xlsx",
                                            "html",
                                            "dotx",
                                            "epub",
                                            "webp",
                                            "gdoc",
                                            "mp3",
                                            "doc",
                                            "txt",
                                            "zip",
                                            "ppt",
                                            "key",
                                            "htm",
                                            "xls",
                                            "odp",
                                            "odt",
                                            "rtf",
                                            "m4a",
                                            "ods",
                                            "mp4",
                                            "ai",
                                            "avi",
                                            "mov",
                                            "wmv",
                                            "mkv",
                                            "wav",
                                            "flac",
                                            "ogg",
                                            "png",
                                            "jpeg",
                                            "jpg",
                                            "gif",
                                            "bmp",
                                            "tiff",
                                            "svg",
                                            "odg",
                                            "sxw",
                                            "sxc",
                                            "sxi",
                                            "rar",
                                            "7z",
                                            "json",
                                            "xml",
                                            "csv",
                                            "md",
                                            "obj",
                                            "stl",
                                            "woff",
                                            "ttf"
                                          ],
                                          "title": "type"
                                        },
                                        "url": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "title",
                                        "type",
                                        "url"
                                      ],
                                      "title": "PostMaterialInterface"
                                    }
                                  }
                                },
                                "required": [
                                  "title",
                                  "visibility",
                                  "contentType",
                                  "description"
                                ],
                                "title": "PostInterface"
                              }
                            }
                          },
                          "required": [
                            "title",
                            "visibility"
                          ],
                          "title": "SubCategoryInterface"
                        }
                      }
                    },
                    "required": [
                      "title",
                      "visibility"
                    ],
                    "title": "CategoryInterface"
                  }
                },
                "instructorDetails": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "description": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "name",
                    "description"
                  ],
                  "title": "InstructorDetails"
                }
              },
              "required": [
                "title",
                "description",
                "categories"
              ],
              "title": "ProductInterface"
            }
          }
        },
        "required": [
          "locationId",
          "products"
        ],
        "title": "PublicExporterPayload"
      },
      "PublicExporterResponseDTO": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          },
          "note": {
            "type": "string"
          },
          "processingCourses": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "title",
                "url"
              ],
              "title": "ProductSkeletonResponseDTO"
            }
          }
        },
        "required": [
          "message"
        ],
        "title": "PublicExporterResponseDTO"
      }
    }
  }
}
```

## HighLevel SDK Examples

**Node.js** (`@gohighlevel/api-client`)

```javascript
import HighLevel from '@gohighlevel/api-client';

const ghl = new HighLevel({
  privateIntegrationToken: '<PRIVATE_INTEGRATION_TOKEN>'
});

const body = {
  "products": [
    {
      "categories": [
        {
          "posts": [
            {
              "postMaterials": []
            }
          ],
          "subCategories": [
            {
              "posts": [
                {
                  "postMaterials": []
                }
              ]
            }
          ]
        }
      ]
    }
  ]
};

const response = await ghl.courses.importCourses(body);
console.log(response);
```

**Python** (`gohighlevel-api-client`)

```python
from highlevel import HighLevel

client = HighLevel(
    private_integration_token='<PRIVATE_INTEGRATION_TOKEN>'
)

body = {
    "products": [
        {
            "categories": [
                {
                    "posts": [
                        {
                            "postMaterials": []
                        }
                    ],
                    "subCategories": [
                        {
                            "posts": [
                                {
                                    "postMaterials": []
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ]
}

response = await client.courses.import_courses(body=body)
print(response)
```

**PHP** (`gohighlevel/api-client`)

```php
<?php
require_once 'vendor/autoload.php';

use HighLevel\HighLevel;
use HighLevel\HighLevelConfig;

$config = new HighLevelConfig([
    'privateIntegrationToken' => '<PRIVATE_INTEGRATION_TOKEN>'
]);
$ghl = new HighLevel($config);

$body = [
    'products' => [
        [
            'categories' => [
                [
                    'posts' => [
                        [
                            'postMaterials' => []
                        ]
                    ],
                    'subCategories' => [
                        [
                            'posts' => [
                                [
                                    'postMaterials' => []
                                ]
                            ]
                        ]
                    ]
                ]
            ]
        ]
    ]
];

$response = $ghl->courses->importCourses($body);
echo json_encode($response, JSON_PRETTY_PRINT);
```

## Code Examples

**cURL**

```bash
curl -L -X POST 'https://services.leadconnectorhq.com/courses/courses-exporter/public/import' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: v3' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "products": [
    {
      "categories": [
        {
          "posts": [
            {
              "postMaterials": []
            }
          ],
          "subCategories": [
            {
              "posts": [
                {
                  "postMaterials": []
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}'
```

**Node.js**

```javascript
const options = {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: 'v3',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
      "products": [
        {
          "categories": [
            {
              "posts": [
                {
                  "postMaterials": []
                }
              ],
              "subCategories": [
                {
                  "posts": [
                    {
                      "postMaterials": []
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
  })
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/courses/courses-exporter/public/import', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/courses/courses-exporter/public/import"

headers = {
    "Authorization": "Bearer <TOKEN>",
    "Version": "v3"
}

payload = {
    "products": [
        {
            "categories": [
                {
                    "posts": [
                        {
                            "postMaterials": []
                        }
                    ],
                    "subCategories": [
                        {
                            "posts": [
                                {
                                    "postMaterials": []
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ]
}

response = requests.post(url, json=payload, headers=headers)
print(response.json())
```

**PHP**

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://services.leadconnectorhq.com/courses/courses-exporter/public/import',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v3',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "products": [
    {
      "categories": [
        {
          "posts": [
            {
              "postMaterials": []
            }
          ],
          "subCategories": [
            {
              "posts": [
                {
                  "postMaterials": []
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}',
]);

$response = curl_exec($curl);
curl_close($curl);
echo $response;
```

**Java**

```java
HttpResponse<String> response = Unirest
  .post("https://services.leadconnectorhq.com/courses/courses-exporter/public/import")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .header("Content-Type", "application/json")
  .body("{\"products\":[{\"categories\":[{\"posts\":[{\"postMaterials\":[]}],\"subCategories\":[{\"posts\":[{\"postMaterials\":[]}]}]}]}]}")
  .asString();
```

**Go**

```go
package main

import (
  "fmt"
  "net/http"
  "io"
  "strings"
)

func main() {
  url := "https://services.leadconnectorhq.com/courses/courses-exporter/public/import"
  payload := strings.NewReader(`{
  "products": [
    {
      "categories": [
        {
          "posts": [
            {
              "postMaterials": []
            }
          ],
          "subCategories": [
            {
              "posts": [
                {
                  "postMaterials": []
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}`)
  req, _ := http.NewRequest("POST", url, payload)
  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Version", "v3")

  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := io.ReadAll(res.Body)
  fmt.Println(string(body))
}
```

**Ruby**

```ruby
require 'uri'
require 'net/http'

url = URI("https://services.leadconnectorhq.com/courses/courses-exporter/public/import")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "v3"
request["Content-Type"] = "application/json"
request.body = '{
  "products": [
    {
      "categories": [
        {
          "posts": [
            {
              "postMaterials": []
            }
          ],
          "subCategories": [
            {
              "posts": [
                {
                  "postMaterials": []
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}'

response = http.request(request)
puts response.read_body
```

**PowerShell**

```powershell
$headers = @{
  "Authorization" = "Bearer <TOKEN>"
  "Version" = "v3"
}

$body = '{
  "products": [
    {
      "categories": [
        {
          "posts": [
            {
              "postMaterials": []
            }
          ],
          "subCategories": [
            {
              "posts": [
                {
                  "postMaterials": []
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}'

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/courses/courses-exporter/public/import' -Method 'POST' -Headers $headers -Body $body -ContentType 'application/json'
$response | ConvertTo-Json
```
