(Customers)
- List - Retrieve a list of customers
Create- Create a customer⚠️ Deprecated- Get - Retrieve a customer
- Update - Update a customer
- Delete - Delete a customer
Retrieve a list of customers for the authenticated workspace.
package main
import(
"context"
dubgo "github.com/dubinc/dub-go"
"github.com/dubinc/dub-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := dubgo.New(
dubgo.WithSecurity("DUB_API_KEY"),
)
res, err := s.Customers.List(ctx, operations.GetCustomersRequest{})
if err != nil {
log.Fatal(err)
}
if res != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.GetCustomersRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
[]operations.GetCustomersResponseBody, error
Error Type | Status Code | Content Type |
---|---|---|
sdkerrors.BadRequest | 400 | application/json |
sdkerrors.Unauthorized | 401 | application/json |
sdkerrors.Forbidden | 403 | application/json |
sdkerrors.NotFound | 404 | application/json |
sdkerrors.Conflict | 409 | application/json |
sdkerrors.InviteExpired | 410 | application/json |
sdkerrors.UnprocessableEntity | 422 | application/json |
sdkerrors.RateLimitExceeded | 429 | application/json |
sdkerrors.InternalServerError | 500 | application/json |
sdkerrors.SDKError | 4XX, 5XX | */* |
[Deprecated]: Customer creation can only be done via tracking a lead event. Use the /track/lead endpoint instead.
⚠️ DEPRECATED: This will be removed in a future release, please migrate away from it as soon as possible.
package main
import(
"context"
dubgo "github.com/dubinc/dub-go"
"log"
)
func main() {
ctx := context.Background()
s := dubgo.New(
dubgo.WithSecurity("DUB_API_KEY"),
)
res, err := s.Customers.Create(ctx, nil)
if err != nil {
log.Fatal(err)
}
if res != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.CreateCustomerRequestBody | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.CreateCustomerResponseBody, error
Error Type | Status Code | Content Type |
---|---|---|
sdkerrors.BadRequest | 400 | application/json |
sdkerrors.Unauthorized | 401 | application/json |
sdkerrors.Forbidden | 403 | application/json |
sdkerrors.NotFound | 404 | application/json |
sdkerrors.Conflict | 409 | application/json |
sdkerrors.InviteExpired | 410 | application/json |
sdkerrors.UnprocessableEntity | 422 | application/json |
sdkerrors.RateLimitExceeded | 429 | application/json |
sdkerrors.InternalServerError | 500 | application/json |
sdkerrors.SDKError | 4XX, 5XX | */* |
Retrieve a customer by ID for the authenticated workspace.
package main
import(
"context"
dubgo "github.com/dubinc/dub-go"
"github.com/dubinc/dub-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := dubgo.New(
dubgo.WithSecurity("DUB_API_KEY"),
)
res, err := s.Customers.Get(ctx, operations.GetCustomerRequest{
ID: "<id>",
})
if err != nil {
log.Fatal(err)
}
if res != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.GetCustomerRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.GetCustomerResponseBody, error
Error Type | Status Code | Content Type |
---|---|---|
sdkerrors.BadRequest | 400 | application/json |
sdkerrors.Unauthorized | 401 | application/json |
sdkerrors.Forbidden | 403 | application/json |
sdkerrors.NotFound | 404 | application/json |
sdkerrors.Conflict | 409 | application/json |
sdkerrors.InviteExpired | 410 | application/json |
sdkerrors.UnprocessableEntity | 422 | application/json |
sdkerrors.RateLimitExceeded | 429 | application/json |
sdkerrors.InternalServerError | 500 | application/json |
sdkerrors.SDKError | 4XX, 5XX | */* |
Update a customer for the authenticated workspace.
package main
import(
"context"
dubgo "github.com/dubinc/dub-go"
"github.com/dubinc/dub-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := dubgo.New(
dubgo.WithSecurity("DUB_API_KEY"),
)
res, err := s.Customers.Update(ctx, operations.UpdateCustomerRequest{
ID: "<id>",
})
if err != nil {
log.Fatal(err)
}
if res != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.UpdateCustomerRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.UpdateCustomerResponseBody, error
Error Type | Status Code | Content Type |
---|---|---|
sdkerrors.BadRequest | 400 | application/json |
sdkerrors.Unauthorized | 401 | application/json |
sdkerrors.Forbidden | 403 | application/json |
sdkerrors.NotFound | 404 | application/json |
sdkerrors.Conflict | 409 | application/json |
sdkerrors.InviteExpired | 410 | application/json |
sdkerrors.UnprocessableEntity | 422 | application/json |
sdkerrors.RateLimitExceeded | 429 | application/json |
sdkerrors.InternalServerError | 500 | application/json |
sdkerrors.SDKError | 4XX, 5XX | */* |
Delete a customer from a workspace.
package main
import(
"context"
dubgo "github.com/dubinc/dub-go"
"log"
)
func main() {
ctx := context.Background()
s := dubgo.New(
dubgo.WithSecurity("DUB_API_KEY"),
)
res, err := s.Customers.Delete(ctx, "<id>")
if err != nil {
log.Fatal(err)
}
if res != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
id |
string | ✔️ | The unique ID of the customer. You may use either the customer's id on Dub (obtained via /customers endpoint) or their externalId (unique ID within your system, prefixed with ext_ , e.g. ext_123 ). |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.DeleteCustomerResponseBody, error
Error Type | Status Code | Content Type |
---|---|---|
sdkerrors.BadRequest | 400 | application/json |
sdkerrors.Unauthorized | 401 | application/json |
sdkerrors.Forbidden | 403 | application/json |
sdkerrors.NotFound | 404 | application/json |
sdkerrors.Conflict | 409 | application/json |
sdkerrors.InviteExpired | 410 | application/json |
sdkerrors.UnprocessableEntity | 422 | application/json |
sdkerrors.RateLimitExceeded | 429 | application/json |
sdkerrors.InternalServerError | 500 | application/json |
sdkerrors.SDKError | 4XX, 5XX | */* |