> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://humanloop.com/docs/v5/api/directories/create/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://humanloop.com/_mcp/server. # Create POST https://api.humanloop.com/v5/directories Content-Type: application/json Creates a Directory. Reference: https://humanloop.com/docs/api/directories/create ## Authentication - `X-API-KEY` header (required) — API Key authentication via header ## Request ### Body (application/json) This endpoint expects an object. - `name` (string, optional) — Name of the directory to create. - `parent_id` (string, optional) — ID of the parent directory. Starts with `dir_`. - `path` (string, optional) — Path to create the directory in, relative to the root directory. If the path does not exist, it will be created. Includes name, e.g. `path/to/directory`. ## Response ### 201 Successful Response - `id` (string, required) — String ID of directory. Starts with `dir_`. - `name` (string, required) — Name of the directory. - `path` (string, required) — Path to the directory, relative to the root directory. Includes name, e.g. `path/to/directory`. - `tags` (list of string, required) — List of tags associated with the directory. - `created_at` (datetime, required) - `updated_at` (datetime, required) - `parent_id` (string, optional) — ID of the parent directory. Will be `None` if the directory is the root directory. Starts with `dir_`. - `description` (string, optional) — Description of the directory. - `readme` (string, optional) — Long description of the directory. ## Errors ### 422 Create Directories Post Request Unprocessable Entity Error Validation Error - `detail` (list of ValidationError, optional) ## Types ### ValidationError - `loc` (list of ValidationErrorLocItem, required) - `msg` (string, required) - `type` (string, required) ### ValidationErrorLocItem ## Examples **Request** ```json {} ``` **Response** ```json { "id": "id", "name": "name", "path": "path", "tags": [ "tags" ], "created_at": "2024-01-15T09:30:00Z", "updated_at": "2024-01-15T09:30:00Z", "parent_id": "parent_id", "description": "description", "readme": "readme" } ``` **SDK Code** ```python import requests url = "https://api.humanloop.com/v5/directories" payload = {} headers = { "X-API-KEY": "", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```typescript import { HumanloopClient } from "humanloop"; const client = new HumanloopClient({ apiKey: "YOUR_API_KEY" }); await client.directories.create(); ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.humanloop.com/v5/directories" payload := strings.NewReader("{}") 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.humanloop.com/v5/directories") 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 = "{}" 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.humanloop.com/v5/directories") .header("X-API-KEY", "") .header("Content-Type", "application/json") .body("{}") .asString(); ``` ```php request('POST', 'https://api.humanloop.com/v5/directories', [ 'body' => '{}', 'headers' => [ 'Content-Type' => 'application/json', 'X-API-KEY' => '', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.humanloop.com/v5/directories"); var request = new RestRequest(Method.POST); request.AddHeader("X-API-KEY", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "X-API-KEY": "", "Content-Type": "application/json" ] let parameters = [] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.humanloop.com/v5/directories")! 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() ```