> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.tangerine365.com/llms.txt.
> For full documentation content, see https://docs.tangerine365.com/llms-full.txt.

# Course Subscription

POST https://localhost:8090//api/course/addUserSubscription
Content-Type: application/x-www-form-urlencoded

The `POST /api/user/addUserSubscription`endpoint is used to subscribe a user to a course.

### Request

- Method: POST
    
- Base URL: {{baseUrl}}
    
- Path: /api/user/userStats
    
- Headers:
    
    - Content-Type: application/x-www-form-urlencoded
        
- Body:
    
    - `idst` (text): The user ID
        
    - `course_id` (text): The course ID
        
    - `user_level`(text): The user level assigned to the course upon subscription.
        

### Response

- `success` (boolean): Indicates the success of the request.
    
- `message` (string): Provides additional information
    
- `course` (object): Represents a course with various properties.
    
    - `idCourse` (string): The unique identifier for the course.
        
    - `idCategory` (string): The category ID the course belongs to.
        
    - `code` (string): The code associated with the course.
        
    - `name` (string): The name of the course.
        
    - `description` (string): The description of the course.
        
    - `box_description` (string): The box description of the course.
        
    - `lang_code` (string): The language code for the course.
        
    - `status` (string): The status of the course.
        
    - `course_type` (string): The type of course it is.
        
    - `subscribe_method` (string): The method for subscribing to the course.
        
        - `0` - Only Admin can subscribe users to the course
            
        - `1` - Subscription requires admin approval
            
        - `2` - Subscription is free to all
            
    - `mediumTime` (string)
        
    - `show_rules` (string): Indicates wether to display rules.
        
    - `selling` (string): The selling status of the course.
        
    - `prize` (string): The price of the course.
        
    - `course_demo` (string): The course demo.
        
    - `create_date` (string): The date the course was created.
        
    - `course_edition` (string): The course edition ID.
        
    - `can_subscribe` (string): The subscription availability status.
        
        - `0` - Subscription is closed
            
        - `1` - Subscription is open at all times
            
        - `2` - Subscription is open only when the current date is within the subscription start and end date set on the course (Key: sub_start_date sub_end_date
            
    - `sub_start_date` (string): The start date for subscription.
        
    - `sub_end_date` (string): The end date for subscription.
        
    - `date_begin` (string): The start date of the course.
        
    - `date_end` (string): The end date of the course.
        
    - `img_course` (string): The path/source to the course image

Reference: https://docs.tangerine365.com/tangerine-365-enterprise/course-subscription

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Tangerine365 Enterprise
  version: 1.0.0
paths:
  //api/course/addUserSubscription:
    post:
      operationId: course-subscription
      summary: Course Subscription
      description: >-
        The `POST /api/user/addUserSubscription`endpoint is used to subscribe a
        user to a course.


        ### Request


        - Method: POST
            
        - Base URL: {{baseUrl}}
            
        - Path: /api/user/userStats
            
        - Headers:
            
            - Content-Type: application/x-www-form-urlencoded
                
        - Body:
            
            - `idst` (text): The user ID
                
            - `course_id` (text): The course ID
                
            - `user_level`(text): The user level assigned to the course upon subscription.
                

        ### Response


        - `success` (boolean): Indicates the success of the request.
            
        - `message` (string): Provides additional information
            
        - `course` (object): Represents a course with various properties.
            
            - `idCourse` (string): The unique identifier for the course.
                
            - `idCategory` (string): The category ID the course belongs to.
                
            - `code` (string): The code associated with the course.
                
            - `name` (string): The name of the course.
                
            - `description` (string): The description of the course.
                
            - `box_description` (string): The box description of the course.
                
            - `lang_code` (string): The language code for the course.
                
            - `status` (string): The status of the course.
                
            - `course_type` (string): The type of course it is.
                
            - `subscribe_method` (string): The method for subscribing to the course.
                
                - `0` - Only Admin can subscribe users to the course
                    
                - `1` - Subscription requires admin approval
                    
                - `2` - Subscription is free to all
                    
            - `mediumTime` (string)
                
            - `show_rules` (string): Indicates wether to display rules.
                
            - `selling` (string): The selling status of the course.
                
            - `prize` (string): The price of the course.
                
            - `course_demo` (string): The course demo.
                
            - `create_date` (string): The date the course was created.
                
            - `course_edition` (string): The course edition ID.
                
            - `can_subscribe` (string): The subscription availability status.
                
                - `0` - Subscription is closed
                    
                - `1` - Subscription is open at all times
                    
                - `2` - Subscription is open only when the current date is within the subscription start and end date set on the course (Key: sub_start_date sub_end_date
                    
            - `sub_start_date` (string): The start date for subscription.
                
            - `sub_end_date` (string): The end date for subscription.
                
            - `date_begin` (string): The start date of the course.
                
            - `date_end` (string): The end date of the course.
                
            - `img_course` (string): The path/source to the course image
      tags:
        - ''
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Course Subscription_Response_200'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                idst:
                  type: string
                  description: Unique identifier (ID) of the user.
                course_id:
                  type: string
                  description: Unique identifier (ID) of the course.
                user_level:
                  type: string
                  description: Access level of the user
              required:
                - idst
                - course_id
                - user_level
servers:
  - url: https://localhost:8090
components:
  schemas:
    Course Subscription_Response_200:
      type: object
      properties: {}
      description: Empty response body
      title: Course Subscription_Response_200

```

## SDK Code Examples

```python
import requests

url = "https://localhost:8090//api/course/addUserSubscription"

payload = ""
headers = {"Content-Type": "application/x-www-form-urlencoded"}

response = requests.post(url, data=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://localhost:8090//api/course/addUserSubscription';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/x-www-form-urlencoded'},
  body: new URLSearchParams('')
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

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

func main() {

	url := "https://localhost:8090//api/course/addUserSubscription"

	req, _ := http.NewRequest("POST", url, nil)

	req.Header.Add("Content-Type", "application/x-www-form-urlencoded")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

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

url = URI("https://localhost:8090//api/course/addUserSubscription")

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/x-www-form-urlencoded'

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

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://localhost:8090//api/course/addUserSubscription")
  .header("Content-Type", "application/x-www-form-urlencoded")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://localhost:8090//api/course/addUserSubscription', [
  'form_params' => null,
  'headers' => [
    'Content-Type' => 'application/x-www-form-urlencoded',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://localhost:8090//api/course/addUserSubscription");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Content-Type": "application/x-www-form-urlencoded"]

let request = NSMutableURLRequest(url: NSURL(string: "https://localhost:8090//api/course/addUserSubscription")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```