Cannot set cache_ttl via API

Hi,

I saw here 11937 that it is possible to set the cache_ttl value for each individual card. The post shows a query to be run against Metabase database but as we are a SaaS client I am not sure how to access this database + I would prefer not to mess with it and use the API instead.

So I have tried doing it using the API but it does not seem to work. All my card-level cache_ttl values remain null. Am I doing anything wrong ?

Here is my code:

card = requests.get(f'{metabase_url}/api/card/570', headers=headers).json()
print(card['cache_ttl'] is None) # True

requests.put(f'{metabase_url}/api/card/570', headers=headers, json={'cache_ttl': True})
# status_code 202 (success)

card = requests.get(f'{metabase_url}/api/card/570', headers=headers).json()
print(card['cache_ttl'] is None) # Still True

Our environment details :

{
  "browser-info": {
    "language": "fr-FR",
    "platform": "MacIntel",
    "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.61 Safari/537.36",
    "vendor": "Google Inc."
  },
  "system-info": {
    "file.encoding": "UTF-8",
    "java.runtime.name": "OpenJDK Runtime Environment",
    "java.runtime.version": "11.0.12+7",
    "java.vendor": "Eclipse Foundation",
    "java.vendor.url": "https://adoptium.net/",
    "java.version": "11.0.12",
    "java.vm.name": "OpenJDK 64-Bit Server VM",
    "java.vm.version": "11.0.12+7",
    "os.name": "Linux",
    "os.version": "4.14.219-164.354.amzn2.x86_64",
    "user.language": "en",
    "user.timezone": "GMT"
  },
  "metabase-info": {
    "databases": [
      "postgres",
      "h2"
    ],
    "hosting-env": "unknown",
    "application-database": "postgres",
    "application-database-details": {
      "database": {
        "name": "PostgreSQL",
        "version": "11.9"
      },
      "jdbc-driver": {
        "name": "PostgreSQL JDBC Driver",
        "version": "42.2.18"
      }
    },
    "run-mode": "prod",
    "version": {
      "date": "2021-09-21",
      "tag": "v1.40.5",
      "branch": "release-x.40.x",
      "hash": "042a36e"
    },
    "settings": {
      "report-timezone": "Europe/Berlin"
    }
  }
}

Hi @AnatoleC
The API has never exposed the cache_ttl. The newer 1.41.0 allows advanced caching control on Pro and Enterprise plans.

Hi @flamber,
The API doc mentions it : https://www.metabase.com/docs/latest/api-documentation.html#put-apicardid

When will 1.41 version be released ? It says we are up to date with version 1.40.5 on our admin page.

Thanks,

@AnatoleC You should read the documentation that follows your version:
https://www.metabase.com/docs/v0.40/api-documentation.html#put-apicardid
We're going to update Metabase Cloud to 1.41.1 some time next week, when it has been released.

1 Like

Hi @flamber
Any update on the upgrade of Metabase Cloud to v1.41 ?
Thanks

@AnatoleC Yes, your instance will be upgraded this week. You should have received an automatic email telling you that last week (sent to the account owner).