> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.coperniq.io/api-reference/work-orders/create-opportunity-work-order/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.coperniq.io/_mcp/server. # Create Opportunity Work Order POST https://api.coperniq.io/v1/opportunities/{opportunity_id}/work-orders Content-Type: application/json Create a new work order for an opportunity. Notes: - `templateId` is required. - `phaseInstanceId` is optional. The phase does not need to be started to create an opportunity work order. **Note:** The `/requests` path is an alias for `/opportunities` and will continue to work until users are individually notified and migrated. Reference: https://docs.coperniq.io/api-reference/work-orders/create-opportunity-work-order ## Authentication - `x-api-key` header (required) — API Key authentication via header ## Request ### Path parameters - `opportunity_id` (integer, required) — Opportunity identifier ### Body (application/json) This endpoint expects an object. - `templateId` (integer, required) — The ID of the work order template to use - `phaseInstanceId` (integer, optional) — Optional. The ID of the phase instance to use. If provided, the phase does not need to be started to create an opportunity work order. You can gather phase instance ids from the get opportunity endpoint. ## Response ### 201 Work order created successfully - `id` (integer, optional) — Created workflow element (task) identifier - `createdAt` (string, optional) - `updatedAt` (string, optional) - `description` (string, optional, nullable) - `position` (integer, optional) — Position within phase - `phaseInstanceId` (integer, optional) - `projectId` (integer, optional) - `createdById` (integer, optional) ## Errors ### 400 Bad Request Error Invalid request - `message` (string, optional) - `code` (enum, optional) - Allowed values: `NOT_FOUND` - `field` (string, optional) — Field that caused the validation error (if applicable) ### 401 Unauthorized Error Authentication failed - `message` (string, optional) - `code` (enum, optional) - Allowed values: `NOT_FOUND` ### 404 Not Found Error Resource not found - `message` (string, optional) - `code` (enum, optional) - Allowed values: `NOT_FOUND` ## Examples **Request** ```json { "templateId": 1 } ``` **Response** ```json { "id": 1, "createdAt": "2024-01-15T09:30:00Z", "updatedAt": "2024-01-15T09:30:00Z", "description": "string", "position": 1, "phaseInstanceId": 1, "projectId": 1, "createdById": 1 } ``` **SDK Code** ```python import requests url = "https://api.coperniq.io/v1/opportunities/1/work-orders" payload = { "templateId": 1 } headers = { "x-api-key": "", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.coperniq.io/v1/opportunities/1/work-orders'; const options = { method: 'POST', headers: {'x-api-key': '', 'Content-Type': 'application/json'}, body: '{"templateId":1}' }; 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.coperniq.io/v1/opportunities/1/work-orders" payload := strings.NewReader("{\n \"templateId\": 1\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("x-api-key", "") 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.coperniq.io/v1/opportunities/1/work-orders") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["x-api-key"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"templateId\": 1\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.coperniq.io/v1/opportunities/1/work-orders") .header("x-api-key", "") .header("Content-Type", "application/json") .body("{\n \"templateId\": 1\n}") .asString(); ``` ```php request('POST', 'https://api.coperniq.io/v1/opportunities/1/work-orders', [ 'body' => '{ "templateId": 1 }', 'headers' => [ 'Content-Type' => 'application/json', 'x-api-key' => '', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.coperniq.io/v1/opportunities/1/work-orders"); var request = new RestRequest(Method.POST); request.AddHeader("x-api-key", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"templateId\": 1\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "x-api-key": "", "Content-Type": "application/json" ] let parameters = ["templateId": 1] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.coperniq.io/v1/opportunities/1/work-orders")! 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() ``` > Official Coperniq API documentation. Build integrations for solar and construction project management — projects, opportunities, work orders, invoices, webhooks, and more.