## Create a task `client.Task.New(ctx, body) (*TaskCreateResponse, error)` **post** `/v1/tasks` Creates a new task record. The `$title` and `$status` fields and the `$assignedTo` relationship are required. If `$createdBy` is omitted it defaults to the authenticated user. The `$note` relationship is read-only — manage notes via their own relationships. Supports idempotency via the `Idempotency-Key` header. **[Required scope](/using-the-api/scopes/):** `tasks:create` **[Rate limit category](/using-the-api/rate-limits/):** Write ### Parameters - `body TaskNewParams` - `Fields param.Field[TaskNewParamsFields]` Field values for the new task. Tasks only support the documented system fields, all prefixed with `$` (e.g. `$title`, `$status`). Required: `$title` (string) and `$status` (one of `TODO`, `IN_PROGRESS`, `COMPLETE`, `CANCELLED`). Call the [definitions endpoint](/api/resources/task/methods/definitions) to discover the available fields. See [Fields and relationships](/using-the-api/fields-and-relationships/) for value type details. - `Status string` Task status. One of: `TODO`, `IN_PROGRESS`, `COMPLETE`, `CANCELLED`. - `Title string` Title of the task. - `Description string` Description of the task in markdown format. - `DueAt string` Due date as an ISO 8601 datetime string. - `Relationships param.Field[map[string, TaskNewParamsRelationshipUnion]]` Relationships to set on the new task. System relationships use a `$` prefix (e.g. `$account`, `$assignedTo`); custom relationships use their bare slug. `$assignedTo` is required. Each value is a single entity ID or an array of IDs. Call the [definitions endpoint](/api/resources/task/methods/definitions) to list available relationship keys. - `map[string, TaskNewParamsRelationshipUnion]` - `string` - `type TaskNewParamsRelationshipArray []string` ### Returns - `type TaskCreateResponse struct{…}` - `ID string` Unique identifier for the entity. - `CreatedAt string` ISO 8601 timestamp of when the entity was created. - `Fields map[string, TaskCreateResponseField]` Map of field names to their typed values. System fields are prefixed with `$` (e.g. `$name`, `$email`); custom attributes use their bare slug. - `Value TaskCreateResponseFieldValueUnion` The field value, or null if unset. - `string` - `float64` - `bool` - `type TaskCreateResponseFieldValueArray []string` - `type TaskCreateResponseFieldValueAddress struct{…}` - `City string` City name. - `Country string` 2-letter ISO 3166-1 alpha-2 country code. - `Latitude float64` Latitude coordinate. - `Longitude float64` Longitude coordinate. - `PostalCode string` Postal or ZIP code. - `State string` State or province. - `Street string` Street address line 1. - `Street2 string` Street address line 2. - `type TaskCreateResponseFieldValueFullName struct{…}` - `FirstName string` The contact's first name. - `LastName string` The contact's last name. - `ValueType string` The data type of the field. - `const TaskCreateResponseFieldValueTypeAddress TaskCreateResponseFieldValueType = "ADDRESS"` - `const TaskCreateResponseFieldValueTypeCheckbox TaskCreateResponseFieldValueType = "CHECKBOX"` - `const TaskCreateResponseFieldValueTypeCurrency TaskCreateResponseFieldValueType = "CURRENCY"` - `const TaskCreateResponseFieldValueTypeDatetime TaskCreateResponseFieldValueType = "DATETIME"` - `const TaskCreateResponseFieldValueTypeEmail TaskCreateResponseFieldValueType = "EMAIL"` - `const TaskCreateResponseFieldValueTypeFullName TaskCreateResponseFieldValueType = "FULL_NAME"` - `const TaskCreateResponseFieldValueTypeMarkdown TaskCreateResponseFieldValueType = "MARKDOWN"` - `const TaskCreateResponseFieldValueTypeMultiSelect TaskCreateResponseFieldValueType = "MULTI_SELECT"` - `const TaskCreateResponseFieldValueTypeNumber TaskCreateResponseFieldValueType = "NUMBER"` - `const TaskCreateResponseFieldValueTypeSingleSelect TaskCreateResponseFieldValueType = "SINGLE_SELECT"` - `const TaskCreateResponseFieldValueTypeSocialHandle TaskCreateResponseFieldValueType = "SOCIAL_HANDLE"` - `const TaskCreateResponseFieldValueTypeTelephone TaskCreateResponseFieldValueType = "TELEPHONE"` - `const TaskCreateResponseFieldValueTypeText TaskCreateResponseFieldValueType = "TEXT"` - `const TaskCreateResponseFieldValueTypeURL TaskCreateResponseFieldValueType = "URL"` - `HTTPLink string` URL to view the entity in the Lightfield web app, or null. - `Relationships map[string, TaskCreateResponseRelationship]` Map of relationship names to their associated entities. System relationships are prefixed with `$` (e.g. `$owner`, `$contact`). - `Cardinality string` Whether the relationship is `has_one` or `has_many`. - `ObjectType string` The type of the related object (e.g. `account`, `contact`). - `Values []string` IDs of the related entities. - `UpdatedAt string` ISO 8601 timestamp of when the entity was last updated, or null. - `ExternalID string` External identifier for the entity, or null if unset. ### Example ```go package main import ( "context" "fmt" "github.com/Lightfld/lightfield-go" "github.com/Lightfld/lightfield-go/option" ) func main() { client := githubcomlightfldlightfieldgo.NewClient( option.WithAPIKey("My API Key"), ) taskCreateResponse, err := client.Task.New(context.TODO(), githubcomlightfldlightfieldgo.TaskNewParams{ Fields: githubcomlightfldlightfieldgo.TaskNewParamsFields{ Status: "$status", Title: "$title", }, Relationships: map[string]githubcomlightfldlightfieldgo.TaskNewParamsRelationshipUnion{ "foo": githubcomlightfldlightfieldgo.TaskNewParamsRelationshipUnion{ OfString: githubcomlightfldlightfieldgo.String("string"), }, }, }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", taskCreateResponse.ID) } ``` #### Response ```json { "id": "id", "createdAt": "createdAt", "fields": { "foo": { "value": "string", "valueType": "ADDRESS" } }, "httpLink": "httpLink", "relationships": { "foo": { "cardinality": "cardinality", "objectType": "objectType", "values": [ "string" ] } }, "updatedAt": "updatedAt", "externalId": "externalId" } ```