I am not aware of an official fasta format description. <strike>The only constraint that I know of is that there should not be any whitespace after `>`</strike>. Apart from that particular position, whitespaces are allowed in the header line.

So, regarding your particular example, both are valid fasta sequences. When in doubt, you can use [`SeqIO`][1] from `Biopython`, if you can parse your file with the following code, it <strike> is</strike> should be a valid fasta file.

    from Bio import SeqIO
    
    with open("example.fasta") as handle:
        for record in SeqIO.parse(handle, "fasta"):
            print(record.id)

Edit per @Chris_Rands' comment

The code below does the same as above, meaning that `SeqIO.parse()` takes care of opening and closing the file.

    from Bio import SeqIO
    
    for record in SeqIO.parse("example.fasta", "fasta"):
        print(record.id)


  [1]: https://biopython.org/wiki/SeqIO