<@U04UQ68083H> How do I patch an array value using...
# ory-copilot
p
@chilly-king-10285 How do I patch an array value using Ory API?
c
A message from kapa.ai
To patch an array value using the Ory API, you can use the
ory patch
command in combination with [JSON Patch](http://jsonpatch.com/) to target individual keys. The format of the patch is a JSON-Patch document. For more details, please check:
Copy code
<https://www.ory.sh/docs/reference/api#operation/patchProject>   <https://jsonpatch.com>
Here's an example of how to patch an array value:
Copy code
ory patch project <your-project-id> \  --replace '/path/to/array/0="new value"'
In this example, replace
<your-project-id>
with your project's ID and
/path/to/array/0
with the path to the array element you want to update. The
0
in the path represents the index of the array element you want to patch. For more complex array updates, you can use JSON Patch operations like
add
,
remove
, and
replace
. For example:
Copy code
ory patch project <your-project-id> \  --add '/path/to/array/-={"key": "value"}'
This command adds a new object with the key-value pair
{"key": "value"}
to the end of the array. Remember to replace
<your-project-id>
with your project's ID and
/path/to/array
with the path to the array you want to update. For more information on using the Ory API to patch resources, refer to the [Ory documentation](https://www.ory.sh/docs/cli/ory-patch).
p
Dumb question, looked up jsonpatch.com, it describes array syntax
🙌 1