← 返回目录
📁 API Reference › BC Partners

取消资产分享

商务中心的管理员用户可以使用本接口取消与某个合作伙伴分享资产。

v1.2与v1.3版本对比

以下表格概括了 v1.2与v1.3 接口的变化。 ``xtable |变化内容{30%}|v1.2{35%}|v1.3{35%}| |---|---|---| |接口路径| /v1.2/bc/partner/asset/delete/|/v1.3/bc/partner/asset/delete/ | |请求参数类型|bc_id: number<br>partner_id: number<br>asset_ids: number[]|bc_id: string <br>partner_id: string<br>asset_ids`: string[]|


## 请求

**地址** https://business-api.tiktok.com/open_api/v1.3/bc/partner/asset/delete/

**方法**  POST

**Header**

``` xtable
|字段|类型|描述|
|---|---|---|
|Access-Token{必填}|string|授权访问令牌。可以通过[获取访问令牌](https://ads.tiktok.com/marketing_api/docs?id=1738373164380162)接口获取。|
|Content-Type{必填}|string|请求消息类型。<br>允许值: `"application/json"`。|

参数

|字段|类型|描述|
|---|---|---|
|bc_id {必填} | string | 商务中心 ID。|
| partner_id {必填} | string | 合作伙伴商务中心 ID。|
|asset_type {必填}|string|资产类型。<br><br>枚举值:<ul><li>`ADVERTISER`:广告账号(广告主账号)。</li><li>`TT_ACCOUNT`:TikTok 账号。此资产类型对应`BC_AUTH_TT`类型的认证身份 。更多信息请参阅 [认证身份](1738958351620097.html)。</li><li>`TIKTOK_SHOP`:TikTok Shop。</li><li>`CATALOG`:商品库。</li><li>`LEAD`:线索。</li><li>`PIXEL`:Pixel。</li><li>`STOREFRANT` <font color="red">已废弃</font></li></ul>|
|asset_ids {必填}|string[]|您要取消共享的资产 ID 列表。<br><br><ul><li>如果 `asset_type` 是 `ADVERTISER`,此字段为广告账号 ID 列表。</li><li>如果 `asset_type` 是 `TT_ACCOUNT`,此字段为商务中心内 TikTok 账号的 ID 列表。</li><li>如果 `asset_type` 是 `TIKTOK_SHOP`,此字段为 TikTok Shop ID 列表。</li><li>如果 `asset_type` 是 `CATALOG`,此字段为商品库 ID 列表。</li><li>如果 `asset_type` 是 `LEAD`,此字段为表单库 ID 列表。目前只允许一个表单库 ID。<ul><li>要获取您有权访问的表单库的更多详细信息,可使用 [/page/library/get/](1740029915327489.html)。</li></ul></li><li>如果 `asset_type` 是 `PIXEL`,此字段为 Pixel ID 列表。</li></ul>|

示例

(code Java java)
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import okhttp3.*;
import org.apache.http.client.utils.URIBuilder;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class Demo {
    private static final String ACCESS_TOKEN = "xxx";
    private static final String PATH = "/open_api/v1.3/bc/partner/asset/delete/";
    private static final ObjectMapper mapper = new ObjectMapper();

    /**
     * Build request URL
     *
     * @param path Request path
     * @return Request URL
     */
    private static String buildUrl(String path) throws URISyntaxException {
        URI uri = new URI("https", "business-api.tiktok.com", path, "", "");
        return uri.toString();
    }


    /**
     * Send POST request
     *
     * @param jsonStr Args in JSON format
     * @return Response in JSON format
     */
    private static String post(String jsonStr) throws IOException, URISyntaxException {
        OkHttpClient client = new OkHttpClient().newBuilder().build();
        String url = buildUrl(PATH);

        RequestBody body = RequestBody.create(MediaType.parse("application/json"), jsonStr);
        Request request = new Request.Builder()
                .url(url)
                .method("POST", body)
                .addHeader("Content-Type", "application/json")
                .addHeader("Access-Token", ACCESS_TOKEN)
                .build();
        Response response = client.newCall(request).execute();
        return response.body().string();
    }


    public static void main(String[] args) throws IOException, URISyntaxException {
        String bc_id = BC_ID;
        String partner_id = PARTNER_ID;
        List < String > asset_ids_list = ASSET_IDS;
        String asset_ids = mapper.writeValueAsString(asset_ids_list);
        String asset_type = ASSET_TYPE;

        // Args in JSON format
        String myArgs = String.format("{\"bc_id\": \"%s\", \"partner_id\": \"%s\", \"asset_ids\": %s, \"asset_type\": \"%s\"}",bc_id, partner_id, asset_ids, asset_type);
        System.out.println(post(myArgs));
    }
}
(/code)

(code Python python)
# coding=utf-8
import json
import requests

from six import string_types
from six.moves.urllib.parse import urlencode, urlunparse  # noqa

ACCESS_TOKEN = "xxx"
PATH = "/open_api/v1.3/bc/partner/asset/delete/"


def build_url(path, query=""):
    # type: (str, str) -> str
    """
    Build request URL
    :param path: Request path
    :param query: Querystring
    :return: Request URL
    """
    scheme, netloc = "https", "business-api.tiktok.com"
    return urlunparse((scheme, netloc, path, "", query, ""))

def post(json_str):
    # type: (str) -> dict
    """
    Send POST request
    :param json_str: Args in JSON format
    :return: Response in JSON format
    """
    url = build_url(PATH)
    args = json.loads(json_str)
    headers = {
        "Access-Token": ACCESS_TOKEN,
        "Content-Type": "application/json",
    }
    rsp = requests.post(url, headers=headers, json=args)
    return rsp.json()


if __name__ == '__main__':
    bc_id = BC_ID
    partner_id = PARTNER_ID
    asset_ids_list = ASSET_IDS
    asset_ids = json.dumps(asset_ids_list)
    asset_type = ASSET_TYPE

    # Args in JSON format
    my_args = "{\"bc_id\": \"%s\", \"partner_id\": \"%s\", \"asset_ids\": %s, \"asset_type\": \"%s\"}" % (bc_id, partner_id, asset_ids, asset_type)
    print(post(my_args))
(/code)

(code PHP php)

$ACCESS_TOKEN = "xxx";
$PATH = "/open_api/v1.3/bc/partner/asset/delete/";

/**
 * Build request URL
 * @param $path : Request path
 * @return string
 */
function build_url($path)
{
    return "https://business-api.tiktok.com" . $path;
}


/**
 * Send POST request
 * @param $json_str : Args in JSON format
 * @return bool|string : Response in JSON format
 */
function post($json_str)
{
    global $ACCESS_TOKEN, $PATH;
    $curl = curl_init();

    $url = build_url($PATH);

    curl_setopt_array($curl, array(
        CURLOPT_URL => $url,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => "",
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => "POST",
        CURLOPT_POSTFIELDS => $json_str,
        CURLOPT_HTTPHEADER => array(
            "Content-Type: application/json",
            "Access-Token: " . $ACCESS_TOKEN,
        ),
    ));

    $response = curl_exec($curl);
    curl_close($curl);
    return $response;
}


$bc_id = BC_ID;
$partner_id = PARTNER_ID;
$asset_ids_list = ASSET_IDS;
$asset_ids = json_encode($asset_ids_list);
$asset_type = ASSET_TYPE;

/* Args in JSON format */
$my_args = sprintf("{\"bc_id\": \"%s\", \"partner_id\": \"%s\", \"asset_ids\": %s, \"asset_type\": \"%s\"}", $bc_id, $partner_id, $asset_ids, $asset_type);
echo post($my_args);
(/code)

(code curl http)
curl -H "Access-Token:xxx" -H "Content-Type:application/json" -X POST \
-d '{
    "bc_id": "BC_ID",
    "partner_id": "PARTNER_ID",
    "asset_ids": [
        "ASSET_IDS"
    ],
    "asset_type": "ASSET_TYPE"
}' \
https://business-api.tiktok.com/open_api/v1.3/bc/partner/asset/delete/ 
(/code)

返回

|字段|类型|描述|
|---|---|---|
|code |number | 返回码。完整返回码列表及描述,可见[附录 - 返回码](https://ads.tiktok.com/marketing_api/docs?id=1737172488964097)。|
|message |string | 返回信息。更多信息可见[附录 - 返回码](https://ads.tiktok.com/marketing_api/docs?id=1737172488964097)。|
|data |object|返回数据。|
|request_id |string|请求的日志ID,唯一标识一个请求。|

示例

(code Success-Response http)
HTTPS/1.1 200 OK
{
    "message": "OK",
    "code": 0,
    "data": {}
} 
(/code)

内容来源:TikTok API for Business 官方文档 · 本地归档

在接这个接口时卡住了?
Stuck wiring this API into production? We build ad-delivery tooling on these platforms — campaign automation, reporting pipelines, error-handling and migration between API versions.
联系我们 · Talk to us 每日平台更新简报 →