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 (for a workspace API key, the member who created the key), or to the assignee when no member is acting. 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"
const TaskCreateResponseFieldValueTypeHTML TaskCreateResponseFieldValueType = "HTML"
Relationships map[string, TaskCreateResponseRelationship]

Map of relationship names to their associated entities. System relationships are prefixed with $ (e.g. $owner, $contact). A self-referential relationship keeps its merged values and includes optional directional values. List filters select the current record’s role with :asSource or :asDestination, for example ?parent:asSource[contains]=account_id.

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.

Directions TaskCreateResponseRelationshipDirectionsOptional

Directional values for a self-referential relationship. List filters use the relationship key with :asSource or :asDestination; writes continue to use the bare key.

AsDestination TaskCreateResponseRelationshipDirectionsAsDestination

The current record is the destination (incoming) endpoint.

Cardinality string

Whether this endpoint direction is HAS_ONE or HAS_MANY.

One of the following:
const TaskCreateResponseRelationshipDirectionsAsDestinationCardinalityHasOne TaskCreateResponseRelationshipDirectionsAsDestinationCardinality = "HAS_ONE"
const TaskCreateResponseRelationshipDirectionsAsDestinationCardinalityHasMany TaskCreateResponseRelationshipDirectionsAsDestinationCardinality = "HAS_MANY"
Values []string

IDs of the related entities in this direction.

AsSource TaskCreateResponseRelationshipDirectionsAsSource

The current record is the source (outgoing) endpoint.

Cardinality string

Whether this endpoint direction is HAS_ONE or HAS_MANY.

One of the following:
const TaskCreateResponseRelationshipDirectionsAsSourceCardinalityHasOne TaskCreateResponseRelationshipDirectionsAsSourceCardinality = "HAS_ONE"
const TaskCreateResponseRelationshipDirectionsAsSourceCardinalityHasMany TaskCreateResponseRelationshipDirectionsAsSourceCardinality = "HAS_MANY"
Values []string

IDs of the related entities in this direction.

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"
      ],
      "directions": {
        "asDestination": {
          "cardinality": "HAS_ONE",
          "values": [
            "string"
          ]
        },
        "asSource": {
          "cardinality": "HAS_ONE",
          "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"
      ],
      "directions": {
        "asDestination": {
          "cardinality": "HAS_ONE",
          "values": [
            "string"
          ]
        },
        "asSource": {
          "cardinality": "HAS_ONE",
          "values": [
            "string"
          ]
        }
      }
    }
  },
  "updatedAt": "updatedAt",
  "externalId": "externalId"
}