機會

機會端點參考

Marketo提供用於讀取、寫入、建立和更新商機記錄的API。 在Marketo中,中繼機會角色物件會將機會記錄連結至銷售線索和聯絡人記錄。 因此,機會可以連結到許多個別銷售機會。

API會公開兩種物件型別。 和大多數Lead Database物件型別一樣,每個物件型別都有對應的Describe呼叫,可傳回物件中繼資料。

商機API為已啟用SFDC SyncMicrosoft Dynamics Sync的訂閱提供唯讀存取權。

說明

使用Lead Database物件的標準模式描述Opportunity記錄。

GET /rest/v1/opportunities/describe.json
{
   "requestId":"185d6#14b51985ff0",
   "success":true,
   "result":[
      {
         "name":"opportunity",
         "displayName":"Opportunity",
         "createdAt":"2015-02-03T22:36:23Z",
         "updatedAt":"2015-02-03T22:36:24Z",
         "idField":"marketoGUID",
         "dedupeFields":[
            "externalOpportunityId"
         ],
         "searchableFields":[
            [
               "externalOpportunityId"
            ],
            [
               "marketoGUID"
            ]
         ],
         "fields":[
            {
               "name":"marketoGUID",
               "displayName":"Marketo GUID",
               "dataType":"string",
               "length":36,
               "updateable":false
            },
            {
               "name":"createdAt",
               "displayName":"Created At",
               "dataType":"datetime",
               "updateable":false
            },
            {
               "name":"updatedAt",
               "displayName":"Updated At",
               "dataType":"datetime",
               "updateable":false
            },
            {
               "name":"externalOpportunityId",
               "displayName":"External Opportunity Id",
               "dataType":"string",
               "length":50,
               "updateable":false
            }
         ]
      }
   ]
}

主要回應欄位包括:

  • idField:識別機會主索引鍵marketoGUID。 這個系統產生的金鑰支援讀取和更新操作,但不支援插入。
  • dedupeFields:識別插入作業的有效金鑰。 對於機會,唯一的索引鍵是externalOpportunityId。
  • searchableFields:識別對查詢有效的欄位。 這些欄位是externalOpportunityId和marketoGUID。

查詢

查詢商機的模式非常遵循Leads API。 但是,filterType引數只接受在對應的Describe回應或dedupeFields的searchableFields陣列中列出的欄位。

對於自訂機會欄位,只有String或Integer型別的欄位會出現在可搜尋的fields陣列中。

GET /rest/v1/opportunities.json?filterType=marketoGUID&filterValues=dff23271-f996-47d7-984f-f2676861b5fa&dff23271-f996-47d7-984f-f2676861b5fc,dff23271-f996-47d7-984f-f2676861b5fb
{
   "requestId":"e42b#14272d07d78",
   "success":true,
   "result":[
      {
         "seq":0,
         "marketoGUID":"dff23271-f996-47d7-984f-f2676861b5fa ",
         "externalOpportunityId":"19UYA31581L000000",
         "name":"Chairs",
         "description":"Chairs",
         "amount":"1604.47",
         "source":"Inbound Sales Call/Email"
      },
      {
         "seq":1,
         "marketoGUID":"dff23271-f996-47d7-984f-f2676861b5fc ",
         "externalOpportunityId":"29UYA31581L000000",
         "name":"Big Dog Day Care-Phase12",
         "description":"Big Dog Day Care-Phase12",
         "amount":"1604.47",
         "source":"Email"
      }
   ]
}

您可以包含下列選用查詢引數:

  • fields:傳回其他機會欄位。
  • nextPageToken:結果集的頁數大於批次大小。
  • batchSize:指定批次大小。 預設值和最大值為300。

當您請求fields的清單時,未傳回的請求欄位具有隱含值null。

建立和更新

機會會遵循銷售機會API模式,但有一些限制。 action值為createOnly、createOrUpdate和updateOnly。

  • 對於createOnly或createOrUpdate模式,請在每個記錄中包含externalOpportunityId欄位。
  • 對於updateOnly模式,請使用marketoGUID或externalOpportunityId。
  • 如果未指定,則模式預設為createOrUpdate。

Leads API中的lookupField引數無法使用。 dedupeBy引數會取代該引數,而且只有在action為updateOnly時才有效。

dedupeBy值為「dedupeFields」和「idField」,Description回應會分別將其識別為externalOpportunityId和marketoGUID。 如果未指定dedupeBy,預設為dedupeFields模式。 'name’欄位不可為Null。

您一次最多可以提交300筆記錄。

POST /rest/v1/opportunities.json
{
   "action":"createOrUpdate",
   "dedupeBy":"dedupeFields",
   "input":[
      {
         "externalOpportunityId":"19UYA31581L000000",
         "name":"Chairs",
         "description":"Chairs",
         "amount":"1604.47",
         "source":"Inbound Sales Call/Email"
      },
      {
         "externalOpportunityId":"29UYA31581L000000",
         "name":"Big Dog Day Care-Phase12",
         "description":"Big Dog Day Care-Phase12",
         "amount":"1604.47",
         "source":"Email"
      }
   ]
}
{
   "requestId":"e42b#14272d07d78",
   "success":true,
   "result":[
      {
         "seq":0,
         "status":"updated",
         "marketoGUID":"dff23271-f996-47d7-984f-f2676861b5fb"
      },
      {
         "seq":1,
         "status":"created",
         "marketoGUID":"cff23271-f996-47d7-984f-f2676861b5fb"
      }
   ]
}

回應包括每個記錄的下列值:

  • marketoGUID:記錄識別碼。
  • status:個別記錄的成功或失敗。
  • seq:提交記錄的索引,此索引會將要求記錄與回應順序建立關聯。

欄位

公司物件包含由顯示名稱、API名稱和dataType等屬性定義的欄位。 這些屬性統稱為中繼資料。

公司物件上的下列端點查詢欄位。 API使用者必須具有具有Read-Write Schema Standard Field許可權、Read-Write Schema Custom Field許可權或兩者的角色。

查詢欄位

依API名稱查詢一個公司欄位或擷取所有公司欄位。

依名稱

依名稱取得機會欄位端點會擷取公司物件上某個欄位的中繼資料。 必要的fieldApiName路徑引數指定欄位的API名稱。

回應類似於Describe Opportunity回應,但包含其他中繼資料。 例如,isCustom屬性指出欄位是否為自訂欄位。

GET /rest/v1/opportunities/schema/fields/externalOpportunityId.json
{
    "requestId": "12331#17e9779cb4b",
    "result": [
        {
            "displayName": "SFDC Oppty Id",
            "name": "externalOpportunityId",
            "description": null,
            "dataType": "string",
            "length": 50,
            "isHidden": false,
            "isHtmlEncodingInEmail": true,
            "isSensitive": false,
            "isCustom": false,
            "isApiCreated": false
        }
    ],
    "success": true
}

瀏覽

取得機會欄位端點會擷取公司物件上所有欄位的中繼資料。 依預設,它最多會傳回300筆記錄。 使用batchSize查詢引數來減少此數目。

如果moreResult屬性為true,則有更多結果可用。 繼續使用傳回的nextPageToken呼叫端點,直到moreResult為false。

GET /rest/v1/opportunities/schema/fields.json?batchSize=5
{
    "requestId": "b4a#17e995b31da",
    "result": [
        {
            "displayName": "SFDC Oppty Id",
            "name": "externalOpportunityId",
            "description": null,
            "dataType": "string",
            "length": 50,
            "isHidden": false,
            "isHtmlEncodingInEmail": true,
            "isSensitive": false,
            "isCustom": false,
            "isApiCreated": false
        },
        {
            "displayName": "Name",
            "name": "name",
            "description": null,
            "dataType": "string",
            "length": 255,
            "isHidden": false,
            "isHtmlEncodingInEmail": true,
            "isSensitive": false,
            "isCustom": false,
            "isApiCreated": false
        },
        {
            "displayName": "Description",
            "name": "description",
            "description": null,
            "dataType": "string",
            "length": 2000,
            "isHidden": false,
            "isHtmlEncodingInEmail": true,
            "isSensitive": false,
            "isCustom": false,
            "isApiCreated": false
        },
        {
            "displayName": "Type",
            "name": "type",
            "description": null,
            "dataType": "string",
            "length": 255,
            "isHidden": false,
            "isHtmlEncodingInEmail": true,
            "isSensitive": false,
            "isCustom": false,
            "isApiCreated": false
        },
        {
            "displayName": "Stage",
            "name": "stage",
            "description": null,
            "dataType": "string",
            "length": 255,
            "isHidden": false,
            "isHtmlEncodingInEmail": true,
            "isSensitive": false,
            "isCustom": false,
            "isApiCreated": false
        }
    ],
    "success": true,
    "nextPageToken": "E5ZONGE4SAHALYYW6FS25KB5BM======",
    "moreResult": true
}

刪除

依重複資料刪除欄位或ID欄位刪除商機。 將deleteBy引數設定為dedupeFields或idField。 預設值為dedupeFields。

要求內文包含要刪除的input機會陣列。 每個通話最多允許300個機會。

POST /rest/v1/opportunities/delete.json
{
   "deleteBy":"dedupeFields",
   "input":[
      {
         "externalOpportunityId":"19UYA31581L000000"
      },
      {
         "externalOpportunityId":"29UYA31581L000000"
      }
   ]
}
{
   "requestId":"e42b#14272d07d78",
   "success":true,
   "result":[
      {
         "seq":0,
         "marketoGUID":"dff23271-f996-47d7-984f-f2676861b5fb",
         "status":"deleted"
      },
      {
         "seq":1,
         "marketoGUID":"cff23271-f996-47d7-984f-f2676861b5fb",
         "status":"deleted"
      }
   ]
}

逾時

  • 除非另有說明,否則機會端點的逾時值為30秒。
  • 同步處理機會的逾時時間為60秒。
  • 刪除商機的逾時時間為60秒。
recommendation-more-help
marketo-developer-help