Skip to main content

Hai Elena,

With the given code I am able to create a new board with a name.

url = "https://api.miro.com/v2/boards"payload = {        "name": "{doc_name}",    "description": "{doc_description}",}headers = {        "accept": "application/json",        "content-type": "application/json",    "authorization": "Bearer {token}",}response = requests.post(url, json=payload, headers=headers)

So far so good, but where can I find the commands and or code to copy an existing board and to
change an existing document. I know that I have to use ‘put’ to copy the board, but I can’t find out more.

I have managed to assemble the above code from https://miroapp.github.io/api-clients/python/miro_api.html#MiroApi.api_client.

Can you please help me out? If I get this all done I have need for 7-10 more licenses for many years to come. So good business I’d say.

Hi @Ernst van der Heijden ,

It is possible to create a copy of an existing board using Copy board API endpoint. Indeed, you need to use a PUT request for that.

You can fill in the desired parameters (copy_from, description, name, etc.) on the page and get a code example or try the endpoint right away.

From the code example you attached I might assume that you are using python. Here is how a python code to copy a board could look like:

import requests

url = "https://api.miro.com/v2/boards?copy_from=board_id"

payload = {
"description": "New description",
"name": "New name",
"teamId": "new_team_id"
}
headers = {
"accept": "application/json",
"content-type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.text)

 


Great Alexander, that works immediataly!

One last question for now:

What is the code for updating an items it’s content? I tried it with:

url = f'https://api.miro.com/v2/boards/{board_id}/items/{item_id}'
data = {"data": {"content": "<p>123</p>"}}headers = {    "accept": "application/json",    "authorization": f"Bearer {access_token}",}response = requests.patch(url, json=data, headers=headers)

Can you help me? And where can I find all the possibilities?


Hi @Ernst van der Heijden ,

The endpoint from your example can be used to update item’s position or parent only: Update item position or parent.

In order to update item’s content you need to use an endpoint specific to the item’s type. E.g. for sticky notes: Update sticky note item.

There item types you can update are: app_cardcarddocumentembedframeimageshapesticky_notetext

You can find the corresponding endpoints in our API reference.


Thanks Alexander,

I’ll give it a try.

 

Kind Regards,

Ernst


Reply