Skip to content

External API routes ​

Overview ​

routes/external-api.php is the integration API that customers call from their own systems (for example to pull assets into a website or another tool). RouteServiceProvider mounts it with prefix external, the api middleware group and the App\Http\Controllers namespace. Every route sits under v1, so all paths start with /external/v1. The file defines 12 routes: one public login route and 11 asset routes.

Controllers: App\Http\Controllers\DAM\v1\External\AuthController and App\Http\Controllers\DAM\v1\External\AssetsController (the asset routes are registered with Route::controller(AssetsController::class)).

MethodPathController@methodAuth
POST/external/v1/loginAuthController@loginPublic
POST/external/v1/get-categoryAssetsController@getCategoryToken
POST/external/v1/get-category-with-fileAssetsController@getCategoryAndFilesToken
POST/external/v1/get-file-by-typeAssetsController@getAllAssetsByTypeToken
POST/external/v1/get-file-detailAssetsController@getDetailToken
POST/external/v1/download-countAssetsController@downloadCountToken
POST/external/v1/download-filesAssetsController@downloadMultipleFilesToken
POST/external/v1/search-assetsAssetsController@SearchAssetsToken
POST/external/v1/generate-embed-codeAssetsController@generateEmbedCodeToken
GET/external/v1/embed-code-listAssetsController@getEmbedAssetsListToken
POST/external/v1/add-tagAssetsController@addTagToAssetsToken
POST/external/v1/get-thumbnailAssetsController@getThumbnailByEmbedToken

Guard, middleware and throttling ​

  • Login has only the api group: LogApiRequests, throttle:api (600 requests per minute, keyed by user id or IP) and SubstituteBindings.
  • Token routes add auth:external-api, external-api and throttle:600,1.
    • auth:external-api is a Passport guard over the external_app provider, model App\Models\DAM\DamExternalApp (fillable: workspace_id, name, url, key, secrete, is_active). The authenticated "user" is the external app record, not a person.
    • external-api (ExternalAPIMiddleware) also requires the token to be named External Api Token. Otherwise it returns {"status": false, "code": 403, "message": "Access denied."} with HTTP 400.
  • Every token route reads the workspace from the app record ($request->user()->workspace_id), not from the request.
  • Most asset routes take a role parameter: the name of an active ACL role (DamAcl) in the app's workspace. Assets are filtered with FIND_IN_SET(role_id, acl_permission), so an app only sees assets that role can see. See Middleware and Assets.

Response envelope and errors ​

All methods return App\RestResource\RestResponse JSON:

HelperHTTPBody
success($data, $msg)200status: true, code: 200, message, data, error: []
validationError($errors)400status: false, code: 400, message: "Woops! Validation is failed.", error (field errors)
warning($msg, $code = 402)402 unless a code is passedstatus: false, code, message
error($msg)500status: false, code: 500, message, data

Errors you will see from every token route:

  • Workspace is not available. (warning, 402): the app's workspace was not found.
  • Invalid Requested role. (error, 500): role does not match an active ACL role. When app.env is production, error() replaces the message with Whoops! Something went wrong., so production callers get a generic 500 for a wrong role name.
  • Any exception: error() with the exception message (generic in production).

POST /external/v1/login ​

Exchanges an app key and secret for a Passport token.

ParamRules
app_keyrequired
secret_keyrequired
  • Looks up DamExternalApp where key = app_key and secrete = secret_key.
  • Success (Login successfully.): data.workspace_id, data.access_token. The token is created with the name External Api Token, which external-api checks.
  • Failure: Invalid App and Secrete key. with HTTP 422.
  • Note: data.workspace_id is set from $damApp->id, the external app's own id, not its workspace_id column.
  • AuthController also has a logout method, but no route points to it.

POST /external/v1/get-category ​

Top-level folders with one level of subfolders.

ParamRules
rolerequired
  • Top-level folders (parent_id null) ordered by folder_name, paginated 15 per page (fixed).
  • Each folder gets workspace_unique_id (workspace url_slug), total_assets (live assets visible to the role), sub_category_count and sub_category_data (subfolders, each with workspace_unique_id, total_assets, sub_category_count).
  • Success message: Folder list has been retrieved successfully. data is a Laravel paginator.

POST /external/v1/get-category-with-file ​

Contents of one folder.

ParamRules
category_idrequired
rolerequired
total_recordoptional, page size (default 48)
sort_valueoptional, sort column (default updated_at)
sort_byoptional, direction (default DESC)
  • data.folder: subfolders with category_name, workspace_unique_id, workspace_name, total_assets, sub_category_count.
  • data.category_assets: paginated live assets in the folder visible to the role, with category and tags.
  • data.breadcrumb: the folder with its parent.
  • Errors: Folder not found. (folder not in the app's workspace), plus the common errors. Success message: Folder with assets fetched successfully.

POST /external/v1/get-file-by-type ​

Assets of one type across all folders.

ParamRules
typerequired, matched against digital_assets.type
rolerequired
total_recordoptional, page size (default 48)
sort_valueoptional (default updated_at)
sort_byoptional (default DESC)
  • Returns a paginator of live assets that have a folder (category_id not null), with tags.
  • Side effect: for each asset whose current version has is_embed_code = 0, the method copies the file to the embed bucket in S3 and sets is_embed_code = 1. Each asset in the response gets is_embed_code and embed_code.
  • Success message: Assets list fetched successfully.

POST /external/v1/get-file-detail ​

One asset.

ParamRules
asset_idrequired
rolerequired
download_byoptional (defaults to desktop)
  • Loads the asset in the app's workspace (not deleted, visible to the role) with category, category.parent and tags. The category is returned as breadcrumb.
  • Side effect: writes a DigitalAssetsDownload row with type = view, IP and location.
  • Errors: Assets not found. Success message: Asset detail fetched successfully.

POST /external/v1/download-count ​

Records a download.

ParamRules
asset_idrequired
rolerequired
  • Inserts a DigitalAssetsDownload row for the workspace and asset. It does not check that the asset belongs to the workspace or is visible to the role.
  • Success: empty data, message Download count added successfully.

POST /external/v1/download-files ​

Download URL for one asset, or a ZIP for several assets and folders.

ParamRules
assets_idrequired, array of asset ids
rolerequired
category_idoptional, array of folder ids (subfolders are included)
download_byoptional (defaults to desktop)
  • Total size 0: You are trying to download empty folder. Over 2 GB (2147483648 bytes): Selected file is too large. Kindly reduce the individual file size below 2 GB to download.
  • One asset and no folders: data.url (the asset's display_file) and data.file_name. Logs a download row.
  • Otherwise builds dam-download-<timestamp>-<app id>.zip under public/upload/dam_assets_zip/ and returns data.url and data.file_name. Logs a download row per asset added.
  • ZIP creation failure: An error occurred creating your ZIP file. Empty ZIP: You are trying to download empty folder. (error, 500).
  • The asset and folder lookups here filter by id only; they do not filter by the app's workspace or the role.
  • Success message: Download successfully.

POST /external/v1/search-assets ​

Search live assets visible to the role.

ParamRules
rolerequired
search_textoptional; matches display_file_name (LIKE) or an exact tag name. A non-empty value also writes a DamSearchHistory row.
typeoptional, asset type
popular_tagoptional, array of tag names
popular_file_typeoptional, array of file types
orientationoptional: horizontal, vertical or square (filtered in PHP from width/height)
start_date, end_dateoptional dates, or all
last_minutesoptional; when truthy the date filter becomes the last 30 minutes
  • data.category_assets: matching assets (not paginated), each with share_url (type=<base64 id>&status=<base64 "single">), workspace_unique_id and tags.
  • The end_date branch checks has('start_date'), so end_date is only read when start_date is also sent.
  • Success message: Search Data.

POST /external/v1/generate-embed-code ​

Turns on the embed code for an asset's current version.

ParamRules
asset_idrequired
rolerequired
  • The asset must be visible to the role (Asset is not available. otherwise). The lookup does not filter by workspace.
  • If the version has no embed yet, copies the file into the embed bucket and sets is_embed_code = 1.
  • data.is_embed_code, data.embed_code. Success message: Embed code generated successfully.

GET /external/v1/embed-code-list ​

Asset versions with an embed code.

ParamRules
rolerequired
  • Returns AssetsVersion rows (id, asset_id, workspace_id, user_id, file_name, display_file_name, thumbnail_file, acl_permission, is_embed_code, embed_code_date) joined to their current asset, not deleted, visible to the role.
  • The query has no workspace_id filter; it relies on the role id in acl_permission.
  • Success message: Embed code list fetched successfully.

POST /external/v1/add-tag ​

Adds one tag to one asset.

ParamRules
asset_idrequired
rolerequired (validated, but not used to check access)
tag_namerequired
  • Creates a DigitalAssetsTag row and returns it. Success message: New Tag added successfully.
  • The duplicate check reads $request->assets_id (plural) while the insert uses asset_id, so the Tag is already exists in this file. warning only fires when the caller also sends assets_id. The method does not check that the asset belongs to the workspace.

POST /external/v1/get-thumbnail ​

Thumbnail URL from an embed key. A comment in the route file says it was added for one customer integration.

ParamRules
workspace_idrequired (validated, but the method uses the app's workspace)
embed_keyrequired
  • Finds the asset whose version has this embed_key and is_embed_code = 1 (Asset is not available. otherwise). The lookup does not filter by workspace.
  • data is the S3 URL of the asset thumbnail, or null when the asset has no thumbnail. Success message: Get thumbnail file successfully.