Create an opportunity
client.Opportunity.New(ctx, body) (*OpportunityCreateResponse, error)
POST/v1/opportunities
Creates a new opportunity record. The $name and $stage fields and the $account relationship are required.
After creation, Lightfield automatically generates an opportunity summary in the background. The $opportunityStatus field is read-only and cannot be set via the API. The $task and $note relationships are also read-only — manage them via the $opportunity relationship on the task, or the $account/$opportunity note relationships instead.
Supports idempotency via the Idempotency-Key header.
To avoid duplicates, we recommend a find-or-create pattern — use list filtering to check if a record exists before creating.
Required scope: opportunities:create
Rate limit category: Write
Create an opportunity
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"),
)
opportunityCreateResponse, err := client.Opportunity.New(context.TODO(), githubcomlightfldlightfieldgo.OpportunityNewParams{
Fields: map[string]githubcomlightfldlightfieldgo.OpportunityNewParamsFieldUnion{
"foo": githubcomlightfldlightfieldgo.OpportunityNewParamsFieldUnion{
OfString: githubcomlightfldlightfieldgo.String("string"),
},
},
Relationships: map[string]githubcomlightfldlightfieldgo.OpportunityNewParamsRelationshipUnion{
"foo": githubcomlightfldlightfieldgo.OpportunityNewParamsRelationshipUnion{
OfString: githubcomlightfldlightfieldgo.String("string"),
},
},
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", opportunityCreateResponse.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"
}