# Organizations ## Create an organization `client.Embed.Organizations.New(ctx, params) (*OrganizationV1, error)` **post** `/v1/organizations` Creates a new organization related to your Straddle integration. Organizations can be used to group related accounts and manage permissions across multiple users. ### Parameters - `params EmbedOrganizationNewParams` - `Name param.Field[string]` Body param: The name of the organization. - `ExternalID param.Field[string]` Body param: Unique identifier for the organization in your database, used for cross-referencing between Straddle and your systems. - `Metadata param.Field[map[string, string]]` Body param: Up to 20 additional user-defined key-value pairs. Useful for storing additional information about the organization in a structured format. - `CorrelationID param.Field[string]` Header param: Optional client generated identifier to trace and debug a series of requests. - `IdempotencyKey param.Field[string]` Header param: Optional client generated value to use for idempotent requests. - `RequestID param.Field[string]` Header param: Optional client generated identifier to trace and debug a request. ### Returns - `type OrganizationV1 struct{…}` - `Data OrganizationV1Data` - `ID string` Straddle's unique identifier for the organization. - `CreatedAt Time` Timestamp of when the organization was created. - `Name string` The name of the organization. - `UpdatedAt Time` Timestamp of the most recent update to the organization. - `ExternalID string` Unique identifier for the organization in your database, used for cross-referencing between Straddle and your systems. - `Metadata map[string, string]` Up to 20 additional user-defined key-value pairs. Useful for storing additional information about the organization in a structured format. - `Meta ResponseMetadata` Metadata about the API request, including an identifier and timestamp. - `APIRequestID string` Unique identifier for this API request, useful for troubleshooting. - `APIRequestTimestamp Time` Timestamp for this API request, useful for troubleshooting. - `ResponseType OrganizationV1ResponseType` Indicates the structure of the returned content. - "object" means the `data` field contains a single JSON object. - "array" means the `data` field contains an array of objects. - "error" means the `data` field contains an error object with details of the issue. - "none" means no data is returned. - `const OrganizationV1ResponseTypeObject OrganizationV1ResponseType = "object"` - `const OrganizationV1ResponseTypeArray OrganizationV1ResponseType = "array"` - `const OrganizationV1ResponseTypeError OrganizationV1ResponseType = "error"` - `const OrganizationV1ResponseTypeNone OrganizationV1ResponseType = "none"` ### Example ```go package main import ( "context" "fmt" "github.com/straddleio/straddle-go" "github.com/straddleio/straddle-go/option" ) func main() { client := straddle.NewClient( option.WithAPIKey("My API Key"), ) organizationV1, err := client.Embed.Organizations.New(context.TODO(), straddle.EmbedOrganizationNewParams{ Name: "name", }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", organizationV1.Data) } ``` #### Response ```json { "data": { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "created_at": "2019-12-27T18:11:19.117Z", "name": "name", "updated_at": "2019-12-27T18:11:19.117Z", "external_id": "external_id", "metadata": { "foo": "string" } }, "meta": { "api_request_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "api_request_timestamp": "2019-12-27T18:11:19.117Z" }, "response_type": "object" } ``` ## List organizations `client.Embed.Organizations.List(ctx, params) (*PageNumberSchema[OrganizationPagedV1Data], error)` **get** `/v1/organizations` Retrieves a list of organizations associated with your Straddle integration. The organizations are returned sorted by creation date, with the most recently created organizations appearing first. This endpoint supports advanced sorting and filtering options to help you find specific organizations. ### Parameters - `params EmbedOrganizationListParams` - `ExternalID param.Field[string]` Query param: List organizations by their external ID. - `Name param.Field[string]` Query param: List organizations by name (partial match supported). - `PageNumber param.Field[int64]` Query param: Results page number. Starts at page 1. - `PageSize param.Field[int64]` Query param: Page size. Max value: 1000 - `SortBy param.Field[string]` Query param: Sort By. - `SortOrder param.Field[EmbedOrganizationListParamsSortOrder]` Query param: Sort Order. - `const EmbedOrganizationListParamsSortOrderAsc EmbedOrganizationListParamsSortOrder = "asc"` - `const EmbedOrganizationListParamsSortOrderDesc EmbedOrganizationListParamsSortOrder = "desc"` - `CorrelationID param.Field[string]` Header param: Optional client generated identifier to trace and debug a series of requests. - `RequestID param.Field[string]` Header param: Optional client generated identifier to trace and debug a request. ### Returns - `type OrganizationPagedV1Data struct{…}` - `ID string` Straddle's unique identifier for the organization. - `CreatedAt Time` Timestamp of when the organization was created. - `Name string` The name of the organization. - `UpdatedAt Time` Timestamp of the most recent update to the organization. - `ExternalID string` Unique identifier for the organization in your database, used for cross-referencing between Straddle and your systems. - `Metadata map[string, string]` Up to 20 additional user-defined key-value pairs. Useful for storing additional information about the organization in a structured format. ### Example ```go package main import ( "context" "fmt" "github.com/straddleio/straddle-go" "github.com/straddleio/straddle-go/option" ) func main() { client := straddle.NewClient( option.WithAPIKey("My API Key"), ) page, err := client.Embed.Organizations.List(context.TODO(), straddle.EmbedOrganizationListParams{ }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "data": [ { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "created_at": "2019-12-27T18:11:19.117Z", "name": "name", "updated_at": "2019-12-27T18:11:19.117Z", "external_id": "external_id", "metadata": { "foo": "string" } } ], "meta": { "api_request_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "api_request_timestamp": "2019-12-27T18:11:19.117Z", "max_page_size": 0, "page_number": 0, "page_size": 0, "sort_by": "sort_by", "sort_order": "asc", "total_items": 0, "total_pages": 0 }, "response_type": "object" } ``` ## Retrieve organization details `client.Embed.Organizations.Get(ctx, organizationID, query) (*OrganizationV1, error)` **get** `/v1/organizations/{organization_id}` Retrieves the details of an Organization that has previously been created. Supply the unique organization ID that was returned from your previous request, and Straddle will return the corresponding organization information. ### Parameters - `organizationID string` - `query EmbedOrganizationGetParams` - `CorrelationID param.Field[string]` Optional client generated identifier to trace and debug a series of requests. - `RequestID param.Field[string]` Optional client generated identifier to trace and debug a request. ### Returns - `type OrganizationV1 struct{…}` - `Data OrganizationV1Data` - `ID string` Straddle's unique identifier for the organization. - `CreatedAt Time` Timestamp of when the organization was created. - `Name string` The name of the organization. - `UpdatedAt Time` Timestamp of the most recent update to the organization. - `ExternalID string` Unique identifier for the organization in your database, used for cross-referencing between Straddle and your systems. - `Metadata map[string, string]` Up to 20 additional user-defined key-value pairs. Useful for storing additional information about the organization in a structured format. - `Meta ResponseMetadata` Metadata about the API request, including an identifier and timestamp. - `APIRequestID string` Unique identifier for this API request, useful for troubleshooting. - `APIRequestTimestamp Time` Timestamp for this API request, useful for troubleshooting. - `ResponseType OrganizationV1ResponseType` Indicates the structure of the returned content. - "object" means the `data` field contains a single JSON object. - "array" means the `data` field contains an array of objects. - "error" means the `data` field contains an error object with details of the issue. - "none" means no data is returned. - `const OrganizationV1ResponseTypeObject OrganizationV1ResponseType = "object"` - `const OrganizationV1ResponseTypeArray OrganizationV1ResponseType = "array"` - `const OrganizationV1ResponseTypeError OrganizationV1ResponseType = "error"` - `const OrganizationV1ResponseTypeNone OrganizationV1ResponseType = "none"` ### Example ```go package main import ( "context" "fmt" "github.com/straddleio/straddle-go" "github.com/straddleio/straddle-go/option" ) func main() { client := straddle.NewClient( option.WithAPIKey("My API Key"), ) organizationV1, err := client.Embed.Organizations.Get( context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", straddle.EmbedOrganizationGetParams{ }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", organizationV1.Data) } ``` #### Response ```json { "data": { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "created_at": "2019-12-27T18:11:19.117Z", "name": "name", "updated_at": "2019-12-27T18:11:19.117Z", "external_id": "external_id", "metadata": { "foo": "string" } }, "meta": { "api_request_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "api_request_timestamp": "2019-12-27T18:11:19.117Z" }, "response_type": "object" } ``` ## Domain Types ### Organization Paged V1 - `type OrganizationPagedV1 struct{…}` - `Data []OrganizationPagedV1Data` - `ID string` Straddle's unique identifier for the organization. - `CreatedAt Time` Timestamp of when the organization was created. - `Name string` The name of the organization. - `UpdatedAt Time` Timestamp of the most recent update to the organization. - `ExternalID string` Unique identifier for the organization in your database, used for cross-referencing between Straddle and your systems. - `Metadata map[string, string]` Up to 20 additional user-defined key-value pairs. Useful for storing additional information about the organization in a structured format. - `Meta PagedResponseMetadata` Metadata about the API request, including an identifier, timestamp, and pagination details. - `APIRequestID string` Unique identifier for this API request, useful for troubleshooting. - `APIRequestTimestamp Time` Timestamp for this API request, useful for troubleshooting. - `MaxPageSize int64` Maximum allowed page size for this endpoint. - `PageNumber int64` Page number for paginated results. - `PageSize int64` Number of items per page in this response. - `SortBy string` The field that the results were sorted by. - `SortOrder PagedResponseMetadataSortOrder` - `const PagedResponseMetadataSortOrderAsc PagedResponseMetadataSortOrder = "asc"` - `const PagedResponseMetadataSortOrderDesc PagedResponseMetadataSortOrder = "desc"` - `TotalItems int64` Total number of items returned in this response. - `TotalPages int64` The number of pages available. - `ResponseType OrganizationPagedV1ResponseType` Indicates the structure of the returned content. - "object" means the `data` field contains a single JSON object. - "array" means the `data` field contains an array of objects. - "error" means the `data` field contains an error object with details of the issue. - "none" means no data is returned. - `const OrganizationPagedV1ResponseTypeObject OrganizationPagedV1ResponseType = "object"` - `const OrganizationPagedV1ResponseTypeArray OrganizationPagedV1ResponseType = "array"` - `const OrganizationPagedV1ResponseTypeError OrganizationPagedV1ResponseType = "error"` - `const OrganizationPagedV1ResponseTypeNone OrganizationPagedV1ResponseType = "none"` ### Organization V1 - `type OrganizationV1 struct{…}` - `Data OrganizationV1Data` - `ID string` Straddle's unique identifier for the organization. - `CreatedAt Time` Timestamp of when the organization was created. - `Name string` The name of the organization. - `UpdatedAt Time` Timestamp of the most recent update to the organization. - `ExternalID string` Unique identifier for the organization in your database, used for cross-referencing between Straddle and your systems. - `Metadata map[string, string]` Up to 20 additional user-defined key-value pairs. Useful for storing additional information about the organization in a structured format. - `Meta ResponseMetadata` Metadata about the API request, including an identifier and timestamp. - `APIRequestID string` Unique identifier for this API request, useful for troubleshooting. - `APIRequestTimestamp Time` Timestamp for this API request, useful for troubleshooting. - `ResponseType OrganizationV1ResponseType` Indicates the structure of the returned content. - "object" means the `data` field contains a single JSON object. - "array" means the `data` field contains an array of objects. - "error" means the `data` field contains an error object with details of the issue. - "none" means no data is returned. - `const OrganizationV1ResponseTypeObject OrganizationV1ResponseType = "object"` - `const OrganizationV1ResponseTypeArray OrganizationV1ResponseType = "array"` - `const OrganizationV1ResponseTypeError OrganizationV1ResponseType = "error"` - `const OrganizationV1ResponseTypeNone OrganizationV1ResponseType = "none"`