It is possible yes.
Here is an example get layout call from postman which you can use to create your code in Anon
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Header>
<urn:SessionHeader xmlns:urn="http://soap.sforce.com/2006/04/metadata">
<urn:sessionId>{{session_id}}</urn:sessionId>
</urn:SessionHeader>
</env:Header>
<env:Body>
<readMetadata xmlns="http://soap.sforce.com/2006/04/metadata">
<type>Layout</type>
<fullNames>{{Layout Name}}</fullNames>
</readMetadata>
</env:Body>
</env:Envelope>
You just need to build the XML yourself and observe the following:
- Content-Type Header: text/xml
- SOAPAction Header: ""
Then it is just a matter of finding the right XML
Here is part of a create Button Example:
'<upsertMetadata xmlns="http://soap.sforce.com/2006/04/metadata">' +
'<metadata xsi:type="WebLink">' +
'<fullName>{{objName}}</fullName>' +
'<availability>online</availability>' +
'<displayType>button</displayType>' +
'<linkType>javascript</linkType>' +
'<masterLabel>{{master_label}}</masterLabel>' +
'<openType>onClickJavaScript</openType>' +
'<protected>false</protected>' +
'<url>{{button_url}}</url>' +
'</metadata>' +
It can also be done from JS on a VF page as an example :
Set OAuthToken Without Apex Metadata Wrapper?