Operations (sample payloads)

Main operations

Create entity

Create an entity of any type in your Microsoft Dynamics 365 account. Sample Input

{
    "instance_url": "https://myorg.crm.dynamics.com",
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik1yNS1BVWliZkJpaTdOZDFqQmViYXhib1hXMCIsImtpZCI6Ik1yNS1BVWliZkJpaTdOZDFqQmViYXhib1hXMCJ9...",
    "entity_set_name": "contacts",
    "fields": [
        \{
            "field": "firstname",
            "value": "John"
        \},
        \{
            "field": "lastname",
            "value": "Doe"
        \},
        \{
            "field": "emailaddress1",
            "value": "john.doe@example.com"
        \},
        \{
            "field": "telephone1",
            "value": "+1 (555) 123-4567"
        \}
    ]
}

Sample Output

{
    "id": "00000000-0000-0000-0000-000000000001"
}

Delete entity

Delete an entity of any type in your Microsoft Dynamics 365 account. Sample Input

\{
    "instance_url": "https://your-org.crm.dynamics.com",
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik1yNS1BVWliZkJpaTdOZDFqQmViYXhib1hXMCIsImtpZCI6Ik1yNS1BVWliZkJpaTdOZDFqQmViYXhib1hXMCJ9...",
    "entity_id": "89a8cde4-5678-901f-2345-67890abcdef1",
    "entity_set_name": "contacts"
\}

Sample Output

{
    "deleted": true
}

Get entity

Get an entity of any type from your Microsoft Dynamics 365 account. Sample Input

\{
    "instance_url": "https://myorg.crm.dynamics.com",
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik1yNS1BVWliZkJpaTdOZDFqQmViYXhib1hXMCIsImtpZCI6Ik1yNS1BVWliZkJpaTdOZDFqQmViYXhib1hXMCJ9...",
    "api_version": "v9.2",
    "entity_id": "00000000-0000-0000-0000-000000000001",
    "entity_set_name": "contacts",
    "fields": [
        "firstname",
        "lastname",
        "emailaddress1",
        "telephone1"
    ]
\}

Sample Output

\{
    "@odata.context": "https://myorg.crm.dynamics.com/api/data/v9.2/$metadata#contacts(firstname,lastname,emailaddress1,telephone1)/$entity",
    "@odata.etag": "W/\"2691174\"",
    "contactid": "00000000-0000-0000-0000-000000000001",
    "firstname": "John",
    "lastname": "Doe",
    "emailaddress1": "johndoe@example.com",
    "telephone1": "+1 (555) 123-4567"
\}

Get user information

Retrieves stored information about the user. Sample Input

\{
    "instance_url": "https://mycompany.crm.dynamics.com",
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik1yNS1BVWliZkJpM...",
    "api_version": "v9.2"
\}

Sample Output

{
    "instance_url": "https://mycompany.crm.dynamics.com",
    "token": \{
        "given_name": "John",
        "name": "John Doe",
        "unique_name": "john.doe@mycompany.com",
        "upn": "john.doe@mycompany.com"
    \}
}

List entities

Get a list of entities from your Microsoft Dynamics 365 account. Sample Input

{
    "instance_url": "https://myorg.crm.dynamics.com",
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik1yNS1BVWliZkJpaTdOZDFqQmViYXhib1hXMCIsImtpZCI6Ik1yNS1BVWliZkJpaTdOZDFqQmViYXhib1hXMCJ9...",
    "entity_set_name": "contacts",
    "fields": [
        "firstname",
        "lastname",
        "emailaddress1"
    ],
    "conditions": [
        \{
            "field": "createdon",
            "operator": "gt",
            "value": "2023-01-01T00:00:00Z"
        \}
    ],
    "conditions_strictness": "and",
    "order_by": [
        \{
            "field": "lastname",
            "order": "asc"
        \}
    ],
    "per_page": 50
}

Sample Output

{
    "@odata.context": "https://myorg.crm.dynamics.com/api/data/v9.2/$metadata#contacts(firstname,lastname,emailaddress1)",
    "value": [
        \{
            "@odata.etag": "W/\"54321\"",
            "firstname": "John",
            "lastname": "Doe",
            "emailaddress1": "john.doe@example.com"
        \},
        \{
            "@odata.etag": "W/\"54322\"",
            "firstname": "Jane",
            "lastname": "Smith",
            "emailaddress1": "jane.smith@example.com"
        \}
    ],
    "@odata.nextLink": "https://myorg.crm.dynamics.com/api/data/v9.2/contacts?$select=firstname,lastname,emailaddress1&$filter=createdon gt 2023-01-01T00:00:00Z&$orderby=lastname asc&$skiptoken=12345",
    "next_page_token": "12345"
}

List entities (raw filter)

Get a list of entities from your Microsoft Dynamics 365 account and filter them with a user defined query. Sample Input

{
    "instance_url": "https://your-org.crm.dynamics.com",
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik1yNS1BVWliZkJpaTdOZDFqQmViYXhib1hXMCIsImtpZCI6Ik1yNS1BVWliZkJpaTdOZDFqQmViYXhib1hXMCJ9...",
    "entity_set_name": "contacts",
    "fields": [
        "firstname",
        "lastname",
        "emailaddress1"
    ],
    "raw_filter": "startswith(lastname, 'Sm')",
    "order_by": [
        \{
            "field": "lastname",
            "order": "asc"
        \}
    ],
    "per_page": 50
}

Sample Output

{
    "@odata.context": "https://your-org.crm.dynamics.com/api/data/v9.2/$metadata#contacts(firstname,lastname,emailaddress1)",
    "value": [
        \{
            "@odata.etag": "W/\"3042492\"",
            "firstname": "John",
            "lastname": "Smith",
            "emailaddress1": "john.smith@example.com"
        \},
        \{
            "@odata.etag": "W/\"3042493\"",
            "firstname": "Jane",
            "lastname": "Smythe",
            "emailaddress1": "jane.smythe@example.com"
        \}
    ],
    "@odata.nextLink": "https://your-org.crm.dynamics.com/api/data/v9.2/contacts?$select=firstname,lastname,emailaddress1&$filter=startswith(lastname, 'Sm')&$orderby=lastname asc&$skiptoken=3042493",
    "next_page_token": "3042493"
}

List entity type attributes

List entity type attributes Sample Input

\{
    "instance_url": "https://myorg.crm.dynamics.com",
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik1yNS1BVWliZkJpaTdOZDFqQmViYXhib1hXMCIsImtpZCI6Ik1yNS1BVWliZkJpaTdOZDFqQmViYXhib1hXMCJ9...",
    "entity_type_metadata_id": "00000000-0000-0000-0000-000000000001",
    "api_version": "9.2",
    "fields": [
        "LogicalName",
        "DisplayName",
        "AttributeType"
    ]
\}

Sample Output

{
    "@odata.context": "https://myorg.crm.dynamics.com/api/data/v9.2/$metadata#EntityDefinitions(00000000-0000-0000-0000-000000000001)/Attributes",
    "value": [
        {
            "LogicalName": "accountnumber",
            "DisplayName": {
                "LocalizedLabels": [
                    \{
                        "Label": "Account Number",
                        "LanguageCode": 1033
                    \}
                ],
                "UserLocalizedLabel": \{
                    "Label": "Account Number",
                    "LanguageCode": 1033
                \}
            },
            "AttributeType": "String"
        },
        {
            "LogicalName": "name",
            "DisplayName": {
                "LocalizedLabels": [
                    \{
                        "Label": "Account Name",
                        "LanguageCode": 1033
                    \}
                ],
                "UserLocalizedLabel": \{
                    "Label": "Account Name",
                    "LanguageCode": 1033
                \}
            },
            "AttributeType": "String"
        }
    ]
}

List entity types

List entity types in Microsoft Dynamics 365 Sample Input

{
    "instance_url": "https://myorg.crm.dynamics.com",
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik1yNS1BVWliZkJpaTdOZDFqQmViYXhib1hXMCIsImtpZCI6Ik1yNS1BVWliZkJpaTdOZDFqQmViYXhib1hXMCJ9...",
    "api_version": "v9.2",
    "fields": [
        "LogicalName",
        "DisplayName",
        "IsCustomEntity",
        "PrimaryNameAttribute"
    ],
    "conditions": [
        \{
            "field": "IsCustomEntity",
            "operator": "eq",
            "value": true
        \},
        \{
            "field": "IsValidForAdvancedFind",
            "operator": "eq",
            "value": true
        \}
    ],
    "conditions_strictness": "and"
}

Sample Output

{
    "@odata.context": "https://myorg.crm.dynamics.com/api/data/v9.2/$metadata#EntityDefinitions(LogicalName,DisplayName,IsCustomEntity,PrimaryNameAttribute)",
    "value": [
        {
            "LogicalName": "new_customentity1",
            "DisplayName": {
                "UserLocalizedLabel": \{
                    "Label": "Custom Entity 1",
                    "LanguageCode": 1033
                \}
            },
            "IsCustomEntity": true,
            "PrimaryNameAttribute": "new_name"
        },
        {
            "LogicalName": "new_customentity2",
            "DisplayName": {
                "UserLocalizedLabel": \{
                    "Label": "Custom Entity 2",
                    "LanguageCode": 1033
                \}
            },
            "IsCustomEntity": true,
            "PrimaryNameAttribute": "new_title"
        }
    ]
}

List one to many relationships

List one to many relationships Sample Input

{
    "instance_url": "https://your-org.crm.dynamics.com",
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik1yNS1BVWliZkJpaTdOZDFqQmViYXhib1hXMCIsImtpZCI6Ik1yNS1BVWliZkJpaTdOZDFqQmViYXhib1hXMCJ9...",
    "api_version": "9.2",
    "fields": [
        "SchemaName",
        "ReferencingEntity",
        "ReferencingAttribute"
    ],
    "conditions": [
        \{
            "field": "ReferencedEntity",
            "operator": "eq",
            "value": "account"
        \}
    ],
    "conditions_strictness": "and"
}

Sample Output

{
    "result": [
        \{
            "MetadataId": "00000000-0000-0000-0000-000000000001",
            "SchemaName": "contact_customer_accounts",
            "ReferencingEntity": "contact",
            "ReferencingAttribute": "parentcustomerid"
        \},
        \{
            "MetadataId": "00000000-0000-0000-0000-000000000002",
            "SchemaName": "opportunity_customer_accounts",
            "ReferencingEntity": "opportunity",
            "ReferencingAttribute": "customerid"
        \},
        \{
            "MetadataId": "00000000-0000-0000-0000-000000000003",
            "SchemaName": "lead_customer_accounts",
            "ReferencingEntity": "lead",
            "ReferencingAttribute": "parentaccountid"
        \}
    ]
}

List status attribute options

Get a list of possible options for a dropdown attribute, such as lead status. Sample Input

\{
    "instance_url": "https://myorg.crm.dynamics.com",
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik1yNS1BVWliZkJpaTdOZDFqQmViYXhib1hXMCIsImtpZCI6Ik1yNS1BVWliZkJpaTdOZDFqQmViYXhib1hXMCJ9...",
    "entity_type": "lead",
    "attribute": "statuscode"
\}

Sample Output

{
    "options": [
        {
            "@odata.type": "#Microsoft.Dynamics.CRM.OptionSetMetadata",
            "Value": 1,
            "Label": {
                "LocalizedLabels": [
                    \{
                        "Label": "New",
                        "LanguageCode": 1033,
                        "IsManaged": true,
                        "MetadataId": "7d8b6c9e-9c9a-4f3a-bb4f-4d41b9e4a9e0",
                        "HasChanged": null
                    \}
                ],
                "UserLocalizedLabel": \{
                    "Label": "New",
                    "LanguageCode": 1033,
                    "IsManaged": true,
                    "MetadataId": "7d8b6c9e-9c9a-4f3a-bb4f-4d41b9e4a9e0",
                    "HasChanged": null
                \}
            },
            "Description": \{
                "LocalizedLabels": [],
                "UserLocalizedLabel": null
            \},
            "Color": "#0000FF",
            "IsManaged": true,
            "MetadataId": null,
            "HasChanged": null,
            "State": 0,
            "TransitionData": ""
        },
        {
            "@odata.type": "#Microsoft.Dynamics.CRM.OptionSetMetadata",
            "Value": 2,
            "Label": {
                "LocalizedLabels": [
                    \{
                        "Label": "Qualified",
                        "LanguageCode": 1033,
                        "IsManaged": true,
                        "MetadataId": "8f8b6c9e-9c9a-4f3a-bb4f-4d41b9e4a9e1",
                        "HasChanged": null
                    \}
                ],
                "UserLocalizedLabel": \{
                    "Label": "Qualified",
                    "LanguageCode": 1033,
                    "IsManaged": true,
                    "MetadataId": "8f8b6c9e-9c9a-4f3a-bb4f-4d41b9e4a9e1",
                    "HasChanged": null
                \}
            },
            "Description": \{
                "LocalizedLabels": [],
                "UserLocalizedLabel": null
            \},
            "Color": "#00FF00",
            "IsManaged": true,
            "MetadataId": null,
            "HasChanged": null,
            "State": 0,
            "TransitionData": ""
        }
    ]
}

Query entity data

Run queries against entity data (uses FetchXML query strings). Enables more advanced operations such as aggregation of data e.g sum, count, max, etc. Sample Input

{
    "instance_url": "https://myorg.crm.dynamics.com",
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik1yNS1BVWliZkJpaTdOZDFqQmViYXhib1hXMCIsImtpZCI6Ik1yNS1BVWliZkJpaTdOZDFqQmViYXhib1hXMCJ9...",
    "entity_type": "account",
    "fields": \{
        "field_list": [
            "name",
            "revenue",
            "numberofemployees"
        ]
    \},
    "conditions": [
        \{
            "field": "revenue",
            "operator": "gt",
            "value": "1000000"
        \},
        \{
            "field": "numberofemployees",
            "operator": "between",
            "value": [
                50,
                500
            ]
        \}
    ],
    "conditions_strictness": "and",
    "sort_order": [
        \{
            "field_name": "revenue",
            "descending": true
        \}
    ],
    "per_page": 10,
    "page": 1
}

Sample Output

{
    "@odata.context": "https://myorg.crm.dynamics.com/api/data/v9.2/$metadata#accounts(name,revenue,numberofemployees)",
    "value": [
        \{
            "name": "Contoso Ltd",
            "revenue": 5000000,
            "numberofemployees": 250,
            "@odata.etag": "W/\"1039834\""
        \},
        \{
            "name": "Fabrikam, Inc.",
            "revenue": 3500000,
            "numberofemployees": 180,
            "@odata.etag": "W/\"1039835\""
        \},
        \{
            "name": "Adventure Works",
            "revenue": 2800000,
            "numberofemployees": 120,
            "@odata.etag": "W/\"1039836\""
        \}
    ]
}

Run fetch XML query (advanced)

Run a raw fetch XML query against the Dynamics instance. Sample Input

\{
    "instance_url": "https://myorg.crm.dynamics.com",
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik1yNS1BVWliZkJpaTdOZDFqQmViYXhib1hXMCIsImtpZCI6Ik1yNS1BVWliZkJpaTdOZDFqQmViYXhib1hXMCJ9...",
    "api_version": "v9.2",
    "entity_set_name": "contacts",
    "xml_query": "<fetch mapping='logical'><entity name='contact'><attribute name='fullname'/><attribute name='emailaddress1'/><filter><condition attribute='createdon' operator='last-x-days' value='30'/></filter></entity></fetch>"
\}

Sample Output

{
    "@odata.context": "https://myorg.crm.dynamics.com/api/data/v9.2/$metadata#contacts(fullname,emailaddress1)",
    "value": [
        \{
            "fullname": "John Doe",
            "emailaddress1": "john.doe@example.com",
            "@odata.etag": "W/\"3042492\""
        \},
        \{
            "fullname": "Jane Smith",
            "emailaddress1": "jane.smith@example.com",
            "@odata.etag": "W/\"3042493\""
        \},
        \{
            "fullname": "Mike Johnson",
            "emailaddress1": "mike.johnson@example.com",
            "@odata.etag": "W/\"3042494\""
        \}
    ]
}

Update entity

Update an entity of any type in your Microsoft Dynamics 365 account. Sample Input

{
    "instance_url": "https://your-org.crm.dynamics.com",
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik...",
    "entity_id": "00000000-0000-0000-0000-000000000001",
    "entity_set_name": "contacts",
    "fields": [
        \{
            "field": "firstname",
            "value": "John"
        \},
        \{
            "field": "lastname",
            "value": "Doe"
        \},
        \{
            "field": "emailaddress1",
            "value": "john.doe@example.com"
        \},
        \{
            "field": "telephone1",
            "value": "+1 (555) 123-4567"
        \}
    ],
    "allow_empty_party_list": false
}

Sample Output

{
    "id": "00000000-0000-0000-0000-000000000001"
}

DDL operations

List entity set attributes (DDL)

Note that DDL operations can only be called directly by Connectors API, or when using CustomJS in the Embedded solution editor for e.g. DDL-dependent data mapping


Sample Input

\{
    "instance_url": "https://myorg.crm.dynamics.com",
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik1yNS1BVWliZkJpaTdOZDFqQmViYXhib1hXMCIsImtpZCI6Ik1yNS1BVWliZkJpaTdOZDFqQmViYXhib1hXMCJ9...",
    "api_version": "v9.2"
\}

Sample Output

{
    "entitySets": [
        {
            "name": "accounts",
            "attributes": [
                \{
                    "name": "accountid",
                    "type": "Edm.Guid",
                    "isKey": true
                \},
                \{
                    "name": "name",
                    "type": "Edm.String"
                \},
                \{
                    "name": "accountnumber",
                    "type": "Edm.String"
                \},
                \{
                    "name": "revenue",
                    "type": "Edm.Decimal"
                \}
            ]
        },
        {
            "name": "contacts",
            "attributes": [
                \{
                    "name": "contactid",
                    "type": "Edm.Guid",
                    "isKey": true
                \},
                \{
                    "name": "firstname",
                    "type": "Edm.String"
                \},
                \{
                    "name": "lastname",
                    "type": "Edm.String"
                \},
                \{
                    "name": "emailaddress1",
                    "type": "Edm.String"
                \}
            ]
        }
    ]
}

List entity sets (DDL)

Note that DDL operations can only be called directly by Connectors API, or when using CustomJS in the Embedded solution editor for e.g. DDL-dependent data mapping


Sample Input

\{
    "instance_url": "https://myorg.crm.dynamics.com",
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik1yNS1BVWliZkJpaTdOZDFqQmViYXhib1hXMCIsImtpZCI6Ik1yNS1BVWliZkJpaTdOZDFqQmViYXhib1hXMCJ9...",
    "api_version": "v9.2"
\}

Sample Output

{
    "value": [
        \{
            "name": "accounts",
            "kind": "EntitySet",
            "url": "accounts"
        \},
        \{
            "name": "contacts",
            "kind": "EntitySet",
            "url": "contacts"
        \},
        \{
            "name": "leads",
            "kind": "EntitySet",
            "url": "leads"
        \},
        \{
            "name": "opportunities",
            "kind": "EntitySet",
            "url": "opportunities"
        \}
    ]
}

List entity type attributes (DDL)

Note that DDL operations can only be called directly by Connectors API, or when using CustomJS in the Embedded solution editor for e.g. DDL-dependent data mapping


Sample Input

\{
    "instance_url": "https://myorg.crm.dynamics.com",
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik1yNS1BVWliZkJpaTdOZDFqQmViYXhib1hXMCIsImtpZCI6Ik1yNS1BVWliZkJpaTdOZDFqQmViYXhib1hXMCJ9...",
    "api_version": "v9.2"
\}

Sample Output

{
    "value": [
        {
            "LogicalName": "accountnumber",
            "DisplayName": {
                "UserLocalizedLabel": \{
                    "Label": "Account Number",
                    "LanguageCode": 1033
                \}
            },
            "AttributeType": "String",
            "IsCustomAttribute": false,
            "IsPrimaryId": false,
            "SchemaName": "AccountNumber"
        },
        {
            "LogicalName": "name",
            "DisplayName": {
                "UserLocalizedLabel": \{
                    "Label": "Account Name",
                    "LanguageCode": 1033
                \}
            },
            "AttributeType": "String",
            "IsCustomAttribute": false,
            "IsPrimaryId": false,
            "SchemaName": "Name"
        },
        {
            "LogicalName": "emailaddress1",
            "DisplayName": {
                "UserLocalizedLabel": \{
                    "Label": "Email",
                    "LanguageCode": 1033
                \}
            },
            "AttributeType": "String",
            "IsCustomAttribute": false,
            "IsPrimaryId": false,
            "SchemaName": "EMailAddress1"
        }
    ]
}

List entity types (DDL)

Note that DDL operations can only be called directly by Connectors API, or when using CustomJS in the Embedded solution editor for e.g. DDL-dependent data mapping


Sample Input

\{
    "instance_url": "https://myorg.crm.dynamics.com",
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik1yNS1BVWliZkJpaTdOZDFqQmViYXhib1hXMCIsImtpZCI6Ik1yNS1BVWliZkJpaTdOZDFqQmViYXhib1hXMCJ9...",
    "api_version": "v9.2"
\}

Sample Output

{
    "value": [
        \{
            "LogicalName": "account",
            "SchemaName": "Account",
            "EntitySetName": "accounts",
            "PrimaryIdAttribute": "accountid",
            "PrimaryNameAttribute": "name",
            "ObjectTypeCode": 1
        \},
        \{
            "LogicalName": "contact",
            "SchemaName": "Contact",
            "EntitySetName": "contacts",
            "PrimaryIdAttribute": "contactid",
            "PrimaryNameAttribute": "fullname",
            "ObjectTypeCode": 2
        \},
        \{
            "LogicalName": "opportunity",
            "SchemaName": "Opportunity",
            "EntitySetName": "opportunities",
            "PrimaryIdAttribute": "opportunityid",
            "PrimaryNameAttribute": "name",
            "ObjectTypeCode": 3
        \}
    ]
}

List party navigation property names (DDL)

Note that DDL operations can only be called directly by Connectors API, or when using CustomJS in the Embedded solution editor for e.g. DDL-dependent data mapping


Sample Input

\{
    "instance_url": "https://myorg.crm.dynamics.com",
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik1yNS1BVWliZkJpaTdOZDFqQmViYXhib1hXMCIsImtpZCI6Ik1yNS1BVWliZkJpaTdOZDFqQmViYXhib1hXMCJ9...",
    "api_version": "v9.2"
\}

Sample Output

{}

Was this page helpful?