---
title: "companyAssignMainContact"
description: "设置公司主要联系人"
doc_type: graphql
doc_category: adminGraphQL
doc_version: v20270301
source_url:
  html: 'https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/b-2-b/mutations/company-assign-main-contact'
  md: 'https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/b-2-b/mutations/company-assign-main-contact.md'
---
# companyAssignMainContact

设置公司主要联系人

- **Required Scopes:** `write_customers`
- **API Version:** v20270301
- **API Type:** Admin
- **API Protocol:** GraphQL
- **Operation Type:** Mutation

## Required Permissions

* `write_customers`

接口访问需要令牌，具体如何获取令牌参考：[身份认证](https://developer.shopline.com/zh-hans-cn/docs/apps/api-instructions-for-use/graph-ql-admin-api/overview.md)。

## Arguments

* `companyContactId`

  [ID!](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/id.md)

  公司联系人id

* `companyId`

  [ID!](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/id.md)

  公司id

## Returns

* `company`

  [Company](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/b-2-b/objects/company.md)

  公司信息

* `userErrors`

  [[BusinessCustomerUserError!]!](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/customers/objects/business-customer-user-error.md)

  错误信息

## Examples

### 设置公司主要联系人

根据联系人id设置主要公司主要联系人

**Request:**

```json
{
  "companyContactId": "gid://shopline/CompanyContact/4217281771",
  "companyId": "gid://shopline/Company/6254924101557166237"
}

```

**Response:**

```json
{
  "data": {
    "data": {
      "companyAssignMainContact": {
        "company": {
          "id": "gid://shopline/Company/6254924101557166237",
          "mainContact": {
            "createdAt": "2023-11-07T10:13:38.117Z",
            "customer": {
              "firstName": "S*****",
              "id": "gid://shopline/Customer/4217281771",
              "state": "ENABLED",
              "createdAt": "2023-11-07T10:13:38.117Z",
              "displayName": "S***** T*****",
              "email": "******@example.com",
              "lastName": "T*****",
              "locale": null,
              "phone": null,
              "updatedAt": "2023-12-21T10:34:54.575Z"
            },
            "id": "gid://shopline/CompanyContact/gid://shopline/CompanyContact/4217281771",
            "updatedAt": "2023-12-21T10:34:54.575Z"
          },
          "name": "test2"
        },
        "userErrors": []
      }
    }
  }
}
```

## Error Handling

关于更多通用错误码说明，参考：[状态码和错误码](https://developer.shopline.com/zh-hans-cn/docs/apps/api-instructions-for-use/graph-ql-admin-api/overview.md#status-and-error-codes)。

