Skip to content

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: tasks:create

Rate limit category: Write

ParametersExpand Collapse
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 to discover the available fields. See 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 stringOptional

Description of the task in markdown format.

DueAt stringOptional

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 to list available relationship keys.

map[string, TaskNewParamsRelationshipUnion]
One of the following:
string
type TaskNewParamsRelationshipArray []string
ReturnsExpand Collapse
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.

One of the following:
string
float64
bool
type TaskCreateResponseFieldValueArray []string
type TaskCreateResponseFieldValueAddress struct{…}
City stringOptional

City name.

Country stringOptional

2-letter ISO 3166-1 alpha-2 country code.

Latitude float64Optional

Latitude coordinate.

Longitude float64Optional

Longitude coordinate.

PostalCode stringOptional

Postal or ZIP code.

State stringOptional

State or province.

Street stringOptional

Street address line 1.

Street2 stringOptional

Street address line 2.

type TaskCreateResponseFieldValueFullName struct{…}
FirstName stringOptional

The contact’s first name.

LastName stringOptional

The contact’s last name.

ValueType string

The data type of the field.

One of the following:
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"
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 stringOptional

External identifier for the entity, or null if unset.

Create a task

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)
}
{
  "id": "id",
  "createdAt": "createdAt",
  "fields": {
    "foo": {
      "value": "string",
      "valueType": "ADDRESS"
    }
  },
  "httpLink": "httpLink",
  "relationships": {
    "foo": {
      "cardinality": "cardinality",
      "objectType": "objectType",
      "values": [
        "string"
      ]
    }
  },
  "updatedAt": "updatedAt",
  "externalId": "externalId"
}
Returns Examples
{
  "id": "id",
  "createdAt": "createdAt",
  "fields": {
    "foo": {
      "value": "string",
      "valueType": "ADDRESS"
    }
  },
  "httpLink": "httpLink",
  "relationships": {
    "foo": {
      "cardinality": "cardinality",
      "objectType": "objectType",
      "values": [
        "string"
      ]
    }
  },
  "updatedAt": "updatedAt",
  "externalId": "externalId"
}