Docs | imagemash.io
DashboardSign up for Free
  • 🎉imagemash.io
  • 🚀Getting Started
    • Simple CDN Link Usage
  • 💽Sources
    • IM Cloud Storage
    • Image URL
    • Storage Providers
      • Amazon S3
      • Google Cloud
      • S3 Compatible Storage
    • Web Folder
  • 🖼️Image Transform
    • Transform Options
      • Quality
      • Width
      • Height
      • Scale
      • Crop
      • Gravity
      • Background
      • Border
      • Round
      • Output Format
      • Angle (Rotate)
      • Flip
      • Helpers
        • x, y
      • Filters
        • Tint
        • Flatten
        • Grayscale
        • Blur
        • Sharpen
        • Median
        • Threshold
        • Negative
    • Transform Cheat Sheet
    • Named Transforms
  • 🛠️API
    • API - Good to knows
    • API Methods
      • Account
        • Named Transforms
          • Get named transforms
          • Add named transform
          • Remove named transform
        • Image URL Restriction
          • Get keyword list
          • Add keyword to list
          • Remove keyword from list
          • Change keyword list usage
      • Storage
        • Upload file
        • Get and search files
        • Delete files
        • Add new tags to files
        • Set tags of files
        • Remove tags from files
        • Purge Cache
      • Optimize / Transform
  • ❓How it works?
    • Custom Domain
    • Bandwidth
    • Cloud Storage
    • Caching
    • Purge Cache
    • Limits
  • Contact Us
Powered by GitBook
On this page
  1. API
  2. API Methods
  3. Storage

Set tags of files

Set tags of files. Discards all tags and inserts the new ones.

POST https://api.imagemash.io/v1/storage/deleteFiles

Headers

Name
Type
Description

apikey*

Your API Key

Request Body

Name
Type
Description

filePaths*

Array

Array of filePaths. Eg. /jeep.png or /cars/jeep.png

tags*

Array

Array of tags to be set. Each tag will be set to every file that filePaths contains. Other tags will be removed. Eg. car, jeep

{
    "successCount": 1,
    "modifiedCount": 0,
    "erroredCount": 2,
    "erroredFiles": [
        "/Asset 1.png",
        "/Asset 2.png"
    ]
}
{
    msg: "error details"
    details: "..."
}   // Explanation of error
Unauthorized
{
    // Please contact support if you are getting this error constantly.
}

Example Codes

curl --location 'https://api.imagemash.io/v1/storage/setTags' \
--header 'apikey: your_api_key' \
--header 'Content-Type: application/json' \
--data '{
    "filePaths": [
        "/Asset 1.png",
        "/Asset 2.png",
        "/Asset 6.png"
    ],
    "tags": [
        "car",
        "jeep"
    ]
}'
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.imagemash.io/v1/storage/setTags");
request.Headers.Add("apikey", "your_api_key");
// Use a JSON library to directly convert your array object into JSON.
// Below code is hardcoded.
var content = new StringContent("{\r\n    \"filePaths\": [\r\n        \"/Asset 1.png\",\r\n        \"/Asset 2.png\",\r\n        \"/Asset 6.png\"\r\n    ],\r\n    \"tags\": [\r\n        \"car\",\r\n        \"jeep\"\r\n    ]\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
import java.io.*;
import okhttp3.*;
public class main {
  public static void main(String []args) throws IOException{
    OkHttpClient client = new OkHttpClient().newBuilder()
      .build();
    MediaType mediaType = MediaType.parse("application/json");
    // Use a JSON library to directly convert your array object into JSON.
    // Below code is hardcoded.
    RequestBody body = RequestBody.create(mediaType, "{\r\n    \"filePaths\": [\r\n        \"/Asset 1.png\",\r\n        \"/Asset 2.png\",\r\n        \"/Asset 6.png\"\r\n    ],\r\n    \"tags\": [\r\n        \"car\",\r\n        \"jeep\"\r\n    ]\r\n}");
    Request request = new Request.Builder()
      .url("https://api.imagemash.io/v1/storage/setTags")
      .method("POST", body)
      .addHeader("apikey", "your_api_key")
      .addHeader("Content-Type", "application/json")
      .build();
    Response response = client.newCall(request).execute();
    System.out.println(response.body().string());
  }
}
var axios = require('axios');
var data = JSON.stringify({
  "filePaths": [
    "/Asset 1.png",
    "/Asset 2.png",
    "/Asset 6.png"
  ],
  "tags": [
    "car",
    "jeep"
  ]
});

var config = {
  method: 'post',
maxBodyLength: Infinity,
  url: 'https://api.imagemash.io/v1/storage/setTags',
  headers: { 
    'apikey': 'your_api_key', 
    'Content-Type': 'application/json'
  },
  maxRedirects: 0,
  data : data
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});
import requests
import json

url = "https://api.imagemash.io/v1/storage/setTags"

payload = json.dumps({
  "filePaths": [
    "/Asset 1.png",
    "/Asset 2.png",
    "/Asset 6.png"
  ],
  "tags": [
    "car",
    "jeep"
  ]
})
headers = {
  'apikey': 'your_api_key',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
require "uri"
require "json"
require "net/http"

url = URI("https://api.imagemash.io/v1/storage/setTags")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["apikey"] = "your_api_key"
request["Content-Type"] = "application/json"
request.body = JSON.dump({
  "filePaths": [
    "/Asset 1.png",
    "/Asset 2.png",
    "/Asset 6.png"
  ],
  "tags": [
    "car",
    "jeep"
  ]
})

response = https.request(request)
puts response.read_body
PreviousAdd new tags to filesNextRemove tags from files

Last updated 2 years ago

🛠️