I’m making a Lucide module (Yes I do understand that there are already many modules for it but a lot of them are outdated) and I have some basic systems working. I know you can use https://apis.roblox.com/assets/v1/assets to read and write assets, but I’m having a hard time figuring out how to grab the asset ID with the Open Cloud Assets API. How would I upload the asset and grab the asset ID, and what would those APIs be?
The reason I’m trying to do this is because it would make my workflow a bit easier so I won’t have to upload and edit everything myself.
By the way the script is being written in Python, just in case.
If more information is required feel free to comment below!
When You use POST https://apis.roblox.com/assets/v1/assets to upload an asset, API will return an operation which has the information if the asset has been processed by Roblox.
Response will look like this:
{
"path": "assets/12345/operation/xyz",
"done": true / false,
"response": {
"assetId": 0, --What You are looking for, present only when "done" = true
}
}
If done is false, Your script needs to wait a couple of seconds and send GET request to https://apis.roblox.com/cloud/v2/X - Replace X with the path value that You got in response. You will recieve a similar object. Repeat until done becomes true and You will get an asset ID for the new asset.
Here’s links for docs with python examples that might help:
Uploading pretty much works, it does upload the assets correctly, but not returning any asset IDs. I’ve been trying quite literally many ways to do this, I even asked AI (please do not mind me) to help me to see if it would help on anything, but to no avail.
This is the generated code:
def upload_to_roblox(file_path, sheet_name):
url = "https://apis.roblox.com/assets/v1/assets"
headers = {"x-api-key": API_KEY}
request_data = {
"assetType": "Decal",
"displayName": sheet_name,
"creationContext": {"creator": {"userId": str(USER_ID)}}
}
try:
print(f"\n📡 Uploading {sheet_name}...")
response = requests.post(url, headers=headers,
files={'request': (None, json.dumps(request_data), 'application/json'),
'fileContent': (os.path.basename(file_path), open(file_path, 'rb'), 'image/png')})
if response.status_code not in [200, 202]:
return "rbxassetid://0"
data = response.json()
path = data.get("path", "")
extracted_id = re.search(r"assets/(\d+)/", path)
if extracted_id:
asset_id = extracted_id.group(1)
print(f"Asset Created (ID extracted from path): {asset_id}")
time.sleep(5)
return f"rbxassetid://{asset_id}"
if path:
poll_url = f"https://apis.roblox.com/cloud/v2/{path}"
for i in range(6):
time.sleep(5)
res = requests.get(poll_url, headers=headers).json()
if res.get("done"):
aid = res.get("response", {}).get("assetId")
print(f"Operation Done! ID: {aid}")
return f"rbxassetid://{aid}"
print(f" ...still pending ({i+1}/6)")
return "rbxassetid://pending_check_dashboard"
except Exception as e:
print(f"Error: {e}")
return "rbxassetid://0"
I probably don’t know what I’m doing anyways so seeing that you have some knowledge on the API, was wondering if you know anything wrong about this?
Also if this may help but the images I’m uploading are pretty large (1024x1024), so maybe it has something to do with that? I don’t know.