Skip to content

미디어 라이브러리에 자산을 업로드하세요.

post

/media_library/create

이 엔드포인트를 사용하여 외부 호스팅된 URL(asset_url) 또는 요청 본문에 전송된 이진 파일 데이터(asset_file)를 사용하여 Braze 미디어 라이브러리에 자산을 추가하세요. 이 엔드포인트는 이미지와 이미지를 포함하는 ZIP 파일을 지원합니다.

필수 조건

이 엔드포인트를 사용하려면 media_library.create 권한이 있는 API 키가 필요합니다.

사용량 제한

이 엔드포인트에는 API 속도 제한 설명서에 명시된 대로 기본값 Braze 속도 제한인 시간당 250,000개의 요청이 적용됩니다.

Request body

asset_url을 포함하면 엔드포인트가 URL에서 파일을 다운로드합니다. asset_file를 포함하면 엔드포인트가 요청 본문의 이진 데이터를 사용합니다.

asset_url에 대한 예제 요청 본문:

1
2
3
4
{
  "asset_url": "https://cdn.example.com/assets/cat.jpg",
  "name": "Cat Graphic"
}

asset_file에 대한 예제 요청 본문:

1
2
3
4
{
  "asset_file": <BINARY FILE DATA>,
  "name": "Cat Graphic"
}

요청 본문에는 다음 매개변수가 포함됩니다:

업로드된 파일 이름

이 섹션에서는 name 매개변수를 포함하는지 여부에 따라 엔드포인트가 업로드된 파일에 이름을 할당하는 방법을 설명합니다.

단일 파일 업로드

ZIP 파일 업로드

예시 요청

이 섹션에는 URL을 사용하여 자산을 추가하는 요청과 이진 파일 데이터를 사용하는 요청의 두 가지 예제 curl 요청이 포함되어 있습니다.

이 요청은 asset_url을 사용하여 미디어 라이브러리에 자산을 추가하는 예를 보여줍니다.

1
2
3
4
curl -X POST --location 'https://rest.iad-01.braze.com/media_library/create' \
--header 'Authorization: Bearer YOUR-REST-API-KEY' \
--header 'Content-Type: application/json' \
--data '{"asset_url": "https://cdn.example.com/assets/cat.jpg", "name": "Cat Graphic"}'

이 요청은 asset_file을 사용하여 미디어 라이브러리에 자산을 추가하는 예를 보여줍니다.

1
2
3
4
curl -X POST --location 'https://rest.iad-01.braze.com/media_library/create' \
--header 'Authorization: Bearer YOUR-REST-API-KEY' \
--header 'Content-Type: application/json' \
--data '{"asset_file":<BINARY FILE DATA>, "name":"Cat Graphic"}'

오류 응답

이 섹션은 잠재적인 오류와 해당 메시지 및 설명을 나열합니다.

유효성 검사 오류

유효성 검사 오류는 다음과 같은 구조를 반환합니다:

1
2
3
{
  "message": (String) Human-readable error description
}

이 표는 가능한 유효성 검사 오류를 나열합니다.

처리 오류

처리 오류는 오류 코드와 함께 다른 응답을 반환합니다:

1
2
3
4
5
{
  "message": (String) Human-readable error description,
  "error_code": (String) error code,
  "meta": { }
}

이 표는 가능한 처리 오류를 나열합니다.

Response

이 엔드포인트에 대한 다섯 가지 상태 코드 응답이 있습니다: 200, 400, 403, 429, 및 500.

다음 JSON은 응답의 예상 형식을 보여줍니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{ 
    "new_assets": [
        {
            "name": (String) the name of the asset,
            "size": (Integer) the byte size of the asset,
            "url": (String) the URL to access the asset,
            "ext": (String) the file extension (e.g., "png", "jpg", "gif")
        }
    ],
    "errors": [
        {
            "name": (String) the name of the asset,
            "size": (Integer) the byte size of the asset,
            "ext": (String) the file extension (e.g., "png", "jpg", "gif"),
            "error": (String) the error that occurred
        }
    ],
    "dashboard_url": (String) the URL to view this asset in the Braze dashboard
}
New Stuff!