> ## Documentation Index
> Fetch the complete documentation index at: https://pinata-mintlify-a8f2129e.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Pin JSON

> Uploads a JSON object to Pinata and pins it to IPFS

<Accordion title="Guide">
  Pinata makes it easy to upload JSON objects using the `pinJSONToIPFS` endpoint.

  ```javascript Pin JSON theme={null}
  const JWT = 'YOUR_PINATA_JWT';

  async function pinJSONToIPFS() {
    try {
      const data = JSON.stringify({
        pinataContent: {
          name: "Pinnie",
          description: "A really sweet NFT of Pinnie the Pinata",
          image: "ipfs://bafkreih5aznjvttude6c3wbvqeebb6rlx5wkbzyppv7garjiubll2ceym4",
          external_url: "https://pinata.cloud"
        },
        pinataMetadata: {
          name: "metadata.json"
        }
      })
      const res = await fetch("https://api.pinata.cloud/pinning/pinJSONToIPFS", {
        method: "POST",
        headers: {
          'Content-Type': 'application/json',
          Authorization: `Bearer ${JWT}`,
        },
        body: data,
      });
      const resData = await res.json();
      console.log(resData);
    } catch (error) {
      console.log(error);
    }
  };

  await pinJSONToIPFS()
  ```
</Accordion>


## OpenAPI

````yaml post /pinning/pinJSONToIPFS
openapi: 3.0.0
info:
  title: Pinata API
  description: ''
  termsOfService: https://www.pinata.cloud/terms-conditions
  contact:
    name: Pinata Team
    email: team@pinata.cloud
  version: 1.0.0
servers:
  - url: https://api.pinata.cloud
security:
  - bearerAuth: []
paths:
  /pinning/pinJSONToIPFS:
    post:
      summary: Pin JSON
      description: Uploads a JSON object to Pinata and pins it to IPFS
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/pinning_pinJSONToIPFS_body'
            examples:
              Example 1:
                value:
                  pinataOptions:
                    cidVersion: 1
                  pinataMetadata:
                    name: pinnie.json
                  pinataContent:
                    somekey: somevalue
      responses:
        '200':
          description: |-
            {
                "IpfsHash": "This is the IPFS multi-hash (CID) provided back for your content,"
                "PinSize": "This is how large (in bytes) the content you just pinned is,"
                "Timestamp": "This is the timestamp for your content pinning (represented in ISO 8601 format)"
            }
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/inline_response_200_1'
      security:
        - bearerAuth: []
      servers:
        - url: https://api.pinata.cloud
components:
  schemas:
    pinning_pinJSONToIPFS_body:
      required:
        - pinataContent
      type: object
      properties:
        pinataContent:
          type: object
          description: The JSON content to pin
        pinataOptions:
          $ref: '#/components/schemas/pinning_pinJSONToIPFS_body_pinataOptions'
        pinataMetadata:
          $ref: '#/components/schemas/pinning_pinJSONToIPFS_body_pinataMetadata'
    inline_response_200_1:
      type: object
      properties:
        IpfsHash:
          type: string
        PinSize:
          type: integer
        Timestamp:
          type: string
        isDuplicate:
          type: boolean
      x-examples:
        Example 1:
          IpfsHash: QmVLwvmGehsrNEvhcCnnsw5RQNseohgEkFNN1848zNzdng
          PinSize: 32942
          Timestamp: '2023-06-16T17:24:37.998Z'
          isDuplicate: true
    pinning_pinJSONToIPFS_body_pinataOptions:
      type: object
      properties:
        groupId:
          type: string
        cidVersion:
          type: number
      description: Optional Pinata Options Object
    pinning_pinJSONToIPFS_body_pinataMetadata:
      type: object
      properties:
        name:
          type: string
        keyvalues:
          type: object
      description: Optional Pinata Metadata object
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````