# Milestones Create Create POST /api/v1/rewards/milestones/create/ Content-Type: application/json Admin only view to create milestones Reference: https://docs.aisquare.studio/api-reference/ai-square-studio-api/rewards/milestones-create-create ## OpenAPI Specification ```yaml openapi: 3.1.0 info: title: AISquare Studio API version: 1.0.0 paths: /api/v1/rewards/milestones/create/: post: operationId: milestones-create-create summary: Milestones Create Create description: Admin only view to create milestones tags: - subpackage_rewards responses: '201': description: '' content: application/json: schema: $ref: '#/components/schemas/Milestone' requestBody: content: application/json: schema: $ref: '#/components/schemas/Milestone' components: schemas: MilestoneTypeEnum: type: string enum: - '1' - '2' - '3' - '4' - '5' - '6' description: |- * `1` - Daily * `2` - Weekly * `3` - Monthly * `4` - Quarterly * `5` - Yearly * `6` - Custom title: MilestoneTypeEnum PriorityEnum: type: string enum: - '1' - '2' - '3' - '4' description: |- * `1` - Low * `2` - Medium * `3` - High * `4` - Urgent title: PriorityEnum MilestoneStatusEnum: type: string enum: - '1' - '2' - '3' description: |- * `1` - Active * `2` - Inactive * `3` - Archived title: MilestoneStatusEnum Milestone: type: object properties: id: type: integer milestone_type: $ref: '#/components/schemas/MilestoneTypeEnum' priority: $ref: '#/components/schemas/PriorityEnum' status: $ref: '#/components/schemas/MilestoneStatusEnum' uid: type: string format: uuid created_at: type: string format: date-time updated_at: type: string format: date-time deleted_at: type: - string - 'null' format: date-time is_active: type: boolean created_by: type: - string - 'null' updated_by: type: - string - 'null' deleted_by: type: - string - 'null' title: type: string description: type: string icon: type: string format: uri period_number: type: integer description: Period number (day, week, month, etc.) year: type: integer description: Year for this milestone is_recurring: type: boolean description: Whether this milestone repeats start_date: type: - string - 'null' format: date description: Start date for custom milestones end_date: type: - string - 'null' format: date description: End date for custom milestones points: type: integer description: Points awarded for completing this milestone required: - id - uid - created_at - updated_at - title - description - icon - period_number - year title: Milestone ``` ## SDK Code Examples ```python import requests url = "https://api.example.com/api/v1/rewards/milestones/create/" payload = { "title": "Quarterly Sales Target", "description": "Achieve the sales target for Q2 2024", "icon": "https://example.com/icons/sales-target.png", "period_number": 2, "year": 2024 } headers = {"Content-Type": "application/json"} response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.example.com/api/v1/rewards/milestones/create/'; const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"title":"Quarterly Sales Target","description":"Achieve the sales target for Q2 2024","icon":"https://example.com/icons/sales-target.png","period_number":2,"year":2024}' }; 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" "strings" "net/http" "io" ) func main() { url := "https://api.example.com/api/v1/rewards/milestones/create/" payload := strings.NewReader("{\n \"title\": \"Quarterly Sales Target\",\n \"description\": \"Achieve the sales target for Q2 2024\",\n \"icon\": \"https://example.com/icons/sales-target.png\",\n \"period_number\": 2,\n \"year\": 2024\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Content-Type", "application/json") 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://api.example.com/api/v1/rewards/milestones/create/") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Content-Type"] = 'application/json' request.body = "{\n \"title\": \"Quarterly Sales Target\",\n \"description\": \"Achieve the sales target for Q2 2024\",\n \"icon\": \"https://example.com/icons/sales-target.png\",\n \"period_number\": 2,\n \"year\": 2024\n}" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.example.com/api/v1/rewards/milestones/create/") .header("Content-Type", "application/json") .body("{\n \"title\": \"Quarterly Sales Target\",\n \"description\": \"Achieve the sales target for Q2 2024\",\n \"icon\": \"https://example.com/icons/sales-target.png\",\n \"period_number\": 2,\n \"year\": 2024\n}") .asString(); ``` ```php request('POST', 'https://api.example.com/api/v1/rewards/milestones/create/', [ 'body' => '{ "title": "Quarterly Sales Target", "description": "Achieve the sales target for Q2 2024", "icon": "https://example.com/icons/sales-target.png", "period_number": 2, "year": 2024 }', 'headers' => [ 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.example.com/api/v1/rewards/milestones/create/"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"title\": \"Quarterly Sales Target\",\n \"description\": \"Achieve the sales target for Q2 2024\",\n \"icon\": \"https://example.com/icons/sales-target.png\",\n \"period_number\": 2,\n \"year\": 2024\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = ["Content-Type": "application/json"] let parameters = [ "title": "Quarterly Sales Target", "description": "Achieve the sales target for Q2 2024", "icon": "https://example.com/icons/sales-target.png", "period_number": 2, "year": 2024 ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/api/v1/rewards/milestones/create/")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data 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() ```